diff options
author | Araq <rumpf_a@web.de> | 2018-10-30 09:21:11 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-10-30 11:28:45 +0100 |
commit | 331d1a6ca1d50df870837b6e5141e1c70e844c35 (patch) | |
tree | 772fb55ea4c5237f142a6a43f7eefe01a65644cb /compiler/semtempl.nim | |
parent | f6def4286c12a2c4a68a3d9e04d562359aeb160b (diff) | |
download | Nim-331d1a6ca1d50df870837b6e5141e1c70e844c35.tar.gz |
fixes regressions
Diffstat (limited to 'compiler/semtempl.nim')
-rw-r--r-- | compiler/semtempl.nim | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 484a7ddd6..a64315037 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -706,28 +706,26 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode = elif templToExpand(s): return semPatternBody(c, semTemplateExpr(c.c, n, s, {efNoSemCheck})) - if n.kind == nkInfix and n.sons[0].kind == nkIdent: + if n.kind == nkInfix and (let id = considerQuotedIdent(c.c, n[0]); id != nil): # we interpret `*` and `|` only as pattern operators if they occur in # infix notation, so that '`*`(a, b)' can be used for verbatim matching: - let opr = n.sons[0] - if opr.ident.s == "*" or opr.ident.s == "**": + if id.s == "*" or id.s == "**": result = newNodeI(nkPattern, n.info, n.len) - result.sons[0] = opr + result.sons[0] = newIdentNode(id, n.info) result.sons[1] = semPatternBody(c, n.sons[1]) result.sons[2] = expectParam(c, n.sons[2]) return - elif opr.ident.s == "|": + elif id.s == "|": result = newNodeI(nkPattern, n.info, n.len) - result.sons[0] = opr + result.sons[0] = newIdentNode(id, n.info) result.sons[1] = semPatternBody(c, n.sons[1]) result.sons[2] = semPatternBody(c, n.sons[2]) return - if n.kind == nkPrefix and n.sons[0].kind == nkIdent: - let opr = n.sons[0] - if opr.ident.s == "~": + if n.kind == nkPrefix and (let id = considerQuotedIdent(c.c, n[0]); id != nil): + if id.s == "~": result = newNodeI(nkPattern, n.info, n.len) - result.sons[0] = opr + result.sons[0] = newIdentNode(id, n.info) result.sons[1] = semPatternBody(c, n.sons[1]) return |