diff --git a/compiler/ast.nim b/compiler/ast.nim index 3ed9a7c675..e35a0b2031 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -933,8 +933,7 @@ proc getPIdent*(a: PNode): PIdent {.inline.} = case a.kind of nkSym: a.sym.name of nkIdent: a.ident - of nkOpenSymChoice, nkClosedSymChoice: a.sons[0].sym.name - of nkOpenSym: getPIdent(a.sons[0]) + of nkOpenSymChoice, nkClosedSymChoice, nkOpenSym: a.sons[0].sym.name else: nil const diff --git a/compiler/lookups.nim b/compiler/lookups.nim index e452da959d..ec5fdd69b0 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -58,13 +58,11 @@ proc considerQuotedIdent*(c: PContext; n: PNode, origin: PNode = nil): PIdent = of nkLiterals - nkFloatLiterals: id.add(x.renderTree) else: handleError(n, origin) result = getIdent(c.cache, id) - of nkOpenSymChoice, nkClosedSymChoice: + of nkOpenSymChoice, nkClosedSymChoice, nkOpenSym: if n[0].kind == nkSym: result = n[0].sym.name else: handleError(n, origin) - of nkOpenSym: - result = considerQuotedIdent(c, n[0], origin) else: handleError(n, origin) diff --git a/compiler/patterns.nim b/compiler/patterns.nim index 32ec7fb537..17e5a86cf9 100644 --- a/compiler/patterns.nim +++ b/compiler/patterns.nim @@ -77,7 +77,7 @@ proc inSymChoice(sc, x: PNode): bool = result = false for i in 0.. 0: result = bracketKind(g, n[0]) else: result = bkNone of nkSym: @@ -1421,10 +1421,7 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) = of nkPrefix: gsub(g, n, 0) if n.len > 1: - let opr = if n[0].kind == nkIdent: n[0].ident - elif n[0].kind == nkSym: n[0].sym.name - elif n[0].kind in {nkOpenSymChoice, nkClosedSymChoice}: n[0][0].sym.name - else: nil + let opr = getPIdent(n[0]) let nNext = skipHiddenNodes(n[1]) if nNext.kind == nkPrefix or (opr != nil and renderer.isKeyword(opr)): put(g, tkSpaces, Space) diff --git a/compiler/reorder.nim b/compiler/reorder.nim index 2f7c04af10..dac316fb75 100644 --- a/compiler/reorder.nim +++ b/compiler/reorder.nim @@ -93,7 +93,7 @@ proc computeDeps(cache: IdentCache; n: PNode, declares, uses: var IntSet; topLev of nkIdent: uses.incl n.ident.id of nkSym: uses.incl n.sym.name.id of nkAccQuoted: uses.incl accQuoted(cache, n).id - of nkOpenSymChoice, nkClosedSymChoice: + of nkOpenSymChoice, nkClosedSymChoice, nkOpenSym: uses.incl n[0].sym.name.id of nkStmtList, nkStmtListExpr, nkWhenStmt, nkElifBranch, nkElse, nkStaticStmt: for i in 0..