From ce72b564bce334b2d8a3b3dbea800557bd842e64 Mon Sep 17 00:00:00 2001 From: metagn Date: Wed, 7 Jun 2023 12:36:51 +0300 Subject: [PATCH] retain forced open undeclared ident information (#22019) --- compiler/semgnrc.nim | 2 +- compiler/semtempl.nim | 7 +++---- tests/lookups/tundeclaredmixin.nim | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 tests/lookups/tundeclaredmixin.nim diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index 44f3969962..70cb64b516 100644 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -64,7 +64,7 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym, template maybeDotChoice(c: PContext, n: PNode, s: PSym, fromDotExpr: bool) = if fromDotExpr: result = symChoice(c, n, s, scForceOpen) - if result.len == 1: + if result.kind == nkOpenSymChoice and result.len == 1: result.transitionSonsKind(nkClosedSymChoice) else: result = symChoice(c, n, s, scOpen) diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 84622f0ad4..9edb2d0ca5 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -70,6 +70,9 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule; onUse(info, s) else: result = n + elif i == 0: + # forced open but symbol not in scope, retain information + result = n else: # semantic checking requires a type; ``fitNode`` deals with it # appropriately @@ -110,14 +113,10 @@ proc semBindStmt(c: PContext, n: PNode, toBind: var IntSet): PNode = proc semMixinStmt(c: PContext, n: PNode, toMixin: var IntSet): PNode = result = copyNode(n) - var count = 0 for i in 0..