From a155130cf2a1ba57501f5b22e4b6818fbc2bd0ae Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 30 Oct 2017 15:37:34 +0100 Subject: [PATCH] fixes #1860; macro generating a wrong nkSymChoice node --- compiler/lookups.nim | 12 ++++++++++-- compiler/semexprs.nim | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index e41fe17f60..65cf504cf5 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -46,7 +46,11 @@ proc considerQuotedIdent*(n: PNode, origin: PNode = nil): PIdent = of nkSym: id.add(x.sym.name.s) else: handleError(n, origin) result = getIdent(id) - of nkOpenSymChoice, nkClosedSymChoice: result = n.sons[0].sym.name + of nkOpenSymChoice, nkClosedSymChoice: + if n[0].kind == nkSym: + result = n.sons[0].sym.name + else: + handleError(n, origin) else: handleError(n, origin) @@ -379,7 +383,11 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = result = errorSym(c, n.sons[1]) of nkClosedSymChoice, nkOpenSymChoice: o.mode = oimSymChoice - result = n.sons[0].sym + if n[0].kind == nkSym: + result = n.sons[0].sym + else: + o.mode = oimDone + return nil o.symChoiceIndex = 1 o.inSymChoice = initIntSet() incl(o.inSymChoice, result.id) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 2a4d5a6202..7a16f495a7 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -2097,7 +2097,7 @@ proc shouldBeBracketExpr(n: PNode): bool = let b = a[0] if b.kind in nkSymChoices: for i in 0..