From 4f7d3631d9cdc84af5e687cf092eef6418dfd0f8 Mon Sep 17 00:00:00 2001 From: metagn <10591326+metagn@users.noreply.github.com> Date: Tue, 19 Dec 2023 22:48:52 +0300 Subject: [PATCH 1/7] preferred syms crude implementation --- compiler/ast.nim | 3 ++- compiler/lookups.nim | 37 +++++++++++++++++++++++++++-- compiler/semexprs.nim | 23 +++++++++--------- compiler/sempass2.nim | 2 +- compiler/semtempl.nim | 23 ++++++++++++++---- compiler/sigmatch.nim | 12 ++++++++-- lib/pure/collections/hashcommon.nim | 4 ++-- tests/enum/tcrossmodule.nim | 5 ++-- tests/lookups/mpreferredsym.nim | 28 ++++++++++++++++++++++ tests/lookups/tpreferredsym.nim | 21 ++++++++++++++++ 10 files changed, 133 insertions(+), 25 deletions(-) create mode 100644 tests/lookups/mpreferredsym.nim create mode 100644 tests/lookups/tpreferredsym.nim diff --git a/compiler/ast.nim b/compiler/ast.nim index 732763f0fe61b..4d3000aadb089 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -521,6 +521,7 @@ type nfHasComment # node has a comment nfSkipFieldChecking # node skips field visable checking nfOpenSym # node is a captured sym but can be overriden by local symbols + nfPreferredSym # node is a preferred sym in a symchoice TNodeFlags* = set[TNodeFlag] TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 47) @@ -1097,7 +1098,7 @@ const nfFromTemplate, nfDefaultRefsParam, nfExecuteOnReload, nfLastRead, nfFirstWrite, nfSkipFieldChecking, - nfOpenSym} + nfOpenSym, nfPreferredSym} namePos* = 0 patternPos* = 1 # empty except for term rewriting macros genericParamsPos* = 2 diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 52296644dd10a..96f4a725f7c83 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -332,6 +332,8 @@ type m*: PSym mode*: TOverloadIterMode symChoiceIndex*: int + symChoiceLastPreferred: bool + fallback: PSym currentScope: PScope importIdx: int marked: IntSet @@ -611,6 +613,11 @@ proc lookUp*(c: PContext, n: PNode): PSym = var ident = considerQuotedIdent(c, n) result = searchInScopes(c, ident, amb) if result == nil: result = errorUndeclaredIdentifierHint(c, ident, n.info) + of nkOpenSymChoice, nkClosedSymChoice: + if nfPreferredSym in n[0].flags: + result = n[0].sym + else: + result = nil else: internalError(c.config, n.info, "lookUp") return nil @@ -691,6 +698,11 @@ proc qualifiedLookUp*(c: PContext, n: PNode, flags: set[TLookupFlag]): PSym = localError(c.config, n[1].info, "identifier expected, but got: " & renderTree(n[1])) result = errorSym(c, n[1]) + of nkOpenSymChoice, nkClosedSymChoice: + if nfPreferredSym in n[0].flags: + result = n[0].sym + else: + result = nil else: result = nil when false: @@ -723,7 +735,16 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = of nkSym: result = n.sym - o.mode = oimDone + if nfPreferredSym in n.flags: + o.mode = oimSymChoiceLocalLookup + o.symChoiceLastPreferred = true + o.currentScope = c.currentScope + o.it.h = result.name.h + o.it.name = result.name + o.marked = initIntSet() + incl(o.marked, result.id) + else: + o.mode = oimDone of nkDotExpr: result = nil o.mode = oimOtherModule @@ -749,6 +770,7 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = o.mode = oimSymChoice if n[0].kind == nkSym: result = n[0].sym + o.symChoiceLastPreferred = nfPreferredSym in n[0].flags else: o.mode = oimDone return nil @@ -767,6 +789,11 @@ proc lastOverloadScope*(o: TOverloadIter): int = else: o.currentScope.depthLevel of oimSelfModule: result = 1 of oimOtherModule: result = 0 + of oimSymChoice, oimSymChoiceLocalLookup: + if o.symChoiceLastPreferred: + result = 999 + else: + result = -1 else: result = -1 proc nextOverloadIterImports(o: var TOverloadIter, c: PContext, n: PNode): PSym = @@ -820,11 +847,15 @@ proc nextOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = result = nextOverloadIterImports(o, c, n) else: result = nil + if result == nil and o.fallback != nil and o.fallback.id notin o.marked: + result = o.fallback + o.fallback = nil of oimSelfModule: result = nextIdentIter(o.it, c.topLevelScope.symbols) of oimOtherModule: result = nextModuleIter(o.mit, c.graph) of oimSymChoice: + o.symChoiceLastPreferred = false if o.symChoiceIndex < n.len: result = n[o.symChoiceIndex].sym incl(o.marked, result.id) @@ -849,13 +880,15 @@ proc nextOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = else: result = nil of oimSymChoiceLocalLookup: + o.symChoiceLastPreferred = false if o.currentScope != nil: result = nextIdentExcluding(o.it, o.currentScope.symbols, o.marked) while result == nil: o.currentScope = o.currentScope.parent if o.currentScope != nil: + let name = if n.kind == nkSym: n.sym.name else: n[0].sym.name result = firstIdentExcluding(o.it, o.currentScope.symbols, - n[0].sym.name, o.marked) + name, o.marked) else: o.importIdx = 0 result = symChoiceExtension(o, c, n) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 67eee3a19a407..92473d521e285 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -101,7 +101,8 @@ proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType elif result.typ.kind == tyError: # associates the type error to the current owner result.typ = errorType(c) - elif efTypeAllowed in flags and result.typ.kind == tyProc and + elif {efTypeAllowed, efOperand} * flags != {} and + result.typ.kind == tyProc and hasUnresolvedParams(result, {}): # mirrored with semOperand but only on efTypeAllowed let owner = result.typ.owner @@ -141,12 +142,7 @@ proc resolveSymChoice(c: PContext, n: var PNode, flags: TExprFlags = {}, expecte # some contexts might want sym choices preserved for later disambiguation # in general though they are ambiguous let first = n[0].sym - var foundSym: PSym = nil - if first.kind == skEnumField and - not isAmbiguous(c, first.name, {skEnumField}, foundSym) and - foundSym == first: - # choose the first resolved enum field, i.e. the latest in scope - # to mirror behavior before overloadable enums + if nfPreferredSym in first.flags: n = n[0] proc semSymChoice(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType = nil): PNode = @@ -1554,8 +1550,7 @@ proc builtinFieldAccess(c: PContext; n: PNode; flags: var TExprFlags): PNode = proc dotTransformation(c: PContext, n: PNode): PNode = if isSymChoice(n[1]) or - # generics usually leave field names as symchoices, but not types - (n[1].kind == nkSym and n[1].sym.kind == skType): + (n[1].kind == nkSym and n[1].sym.kind in routineKinds + {skType}): result = newNodeI(nkDotCall, n.info) result.add n[1] result.add copyTree(n[0]) @@ -2965,13 +2960,17 @@ proc getNilType(c: PContext): PType = c.nilTypeCache = result proc enumFieldSymChoice(c: PContext, n: PNode, s: PSym): PNode = - var o: TOverloadIter + var o: TOverloadIter = default(TOverloadIter) + var firstPreferred = true var i = 0 var a = initOverloadIter(o, c, n) + let firstScope = lastOverloadScope(o) while a != nil: if a.kind == skEnumField: inc(i) - if i > 1: break + if i > 1: + firstPreferred = firstScope > lastOverloadScope(o) + break a = nextOverloadIter(o, c, n) let info = getCallLineInfo(n) if i <= 1: @@ -2991,6 +2990,8 @@ proc enumFieldSymChoice(c: PContext, n: PNode, s: PSym): PNode = result.add newSymNode(a, info) onUse(info, a) a = nextOverloadIter(o, c, n) + if firstPreferred: + result[0].flags.incl nfPreferredSym proc semPragmaStmt(c: PContext; n: PNode) = if c.p.owner.kind == skModule: diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 48a6b9d1c3be0..876bb0758e805 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -1145,7 +1145,7 @@ proc track(tracked: PEffects, n: PNode) = if n.sym.typ != nil and tfHasAsgn in n.sym.typ.flags: tracked.owner.flags.incl sfInjectDestructors # bug #15038: ensure consistency - if not hasDestructor(n.typ) and sameType(n.typ, n.sym.typ): n.typ = n.sym.typ + if n.typ != nil and not hasDestructor(n.typ) and sameType(n.typ, n.sym.typ): n.typ = n.sym.typ of nkHiddenAddr, nkAddr: if n[0].kind == nkSym and isLocalSym(tracked, n[0].sym): useVarNoInitCheck(tracked, n[0], n[0].sym) diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index e572efdc0bec0..ae1d48d1d9ef0 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -52,13 +52,17 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule; isField = false): PNode = var a: PSym - o: TOverloadIter + o: TOverloadIter = default(TOverloadIter) + firstPreferred = true var i = 0 a = initOverloadIter(o, c, n) + let firstScope = lastOverloadScope(o) while a != nil: if a.kind != skModule: inc(i) - if i > 1: break + if i > 1: + firstPreferred = firstScope > lastOverloadScope(o) + break a = nextOverloadIter(o, c, n) let info = getCallLineInfo(n) if i <= 1 and r != scForceOpen: @@ -67,8 +71,17 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule; # for instance 'nextTry' is both in tables.nim and astalgo.nim ... if not isField or sfGenSym notin s.flags: result = newSymNode(s, info) - markUsed(c, info, s) - onUse(info, s) + if r == scClosed or n.kind == nkDotExpr or + (s.magic != mNone and s.kind in routineKinds): + markUsed(c, info, s) + onUse(info, s) + else: + # could maybe instead generate a open symchoice with a preferred sym, + # which the logic for is in the top else branch + # XXX why have this then + result.flags.incl nfPreferredSym + incl(s.flags, sfUsed) + markOwnerModuleAsUsed(c, s) else: result = n elif i == 0: @@ -88,6 +101,8 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule; result.add newSymNode(a, info) onUse(info, a) a = nextOverloadIter(o, c, n) + if r != scForceOpen and firstPreferred: + result[0].flags.incl nfPreferredSym proc semBindStmt(c: PContext, n: PNode, toBind: var IntSet): PNode = result = copyNode(n) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 8f383013090e7..9a5b98ecc3dc7 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -2416,7 +2416,8 @@ proc paramTypesMatch*(m: var TCandidate, f, a: PType, if x.state != csMatch: internalError(m.c.graph.config, arg.info, "x.state is not csMatch") result = nil - if best > -1 and result != nil: + if (best > -1 and result != nil) or + (best = 0; nfPreferredSym in arg[best].flags): # only one valid interpretation found: markUsed(m.c, arg.info, arg[best].sym) onUse(arg.info, arg[best].sym) @@ -2467,6 +2468,13 @@ proc prepareOperand(c: PContext; a: PNode): PNode = result = a considerGenSyms(c, result) +proc finishOperand(c: PContext; a: PNode): PNode = + if a.typ.isNil: + result = c.semExprWithType(c, a, {efOperand, efAllowSymChoice}) + else: + result = a + considerGenSyms(c, result) + proc prepareNamedParam(a: PNode; c: PContext) = if a[0].kind != nkIdent: var info = a[0].info @@ -2708,7 +2716,7 @@ proc semFinishOperands*(c: PContext, n: PNode) = # this needs to be called to ensure that after overloading resolution every # argument has been sem'checked: for i in 1.. Date: Wed, 20 Dec 2023 00:38:43 +0300 Subject: [PATCH 2/7] not sure what caused this --- compiler/sigmatch.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 9a5b98ecc3dc7..1ac835c921c3a 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -246,7 +246,8 @@ proc sumGeneric(t: PType): int = result += sumGeneric(a) break of tyProc: - result += sumGeneric(t.returnType) + if t.returnType != nil: + result += sumGeneric(t.returnType) for _, a in t.paramTypes: result += sumGeneric(a) break From 8d3b41d8e37da590b8430619b641325cc9be4e74 Mon Sep 17 00:00:00 2001 From: metagn <10591326+metagn@users.noreply.github.com> Date: Mon, 25 Dec 2023 20:40:54 +0300 Subject: [PATCH 3/7] explain some stuff, remove unused code --- compiler/lookups.nim | 6 ++---- compiler/semtempl.nim | 14 ++++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 96f4a725f7c83..3ee7673a0d6e7 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -333,7 +333,6 @@ type mode*: TOverloadIterMode symChoiceIndex*: int symChoiceLastPreferred: bool - fallback: PSym currentScope: PScope importIdx: int marked: IntSet @@ -736,6 +735,8 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = of nkSym: result = n.sym if nfPreferredSym in n.flags: + # standalone sym node with nfPreferredSym acts like an open symchoice, + # see semtempl.symChoice for reasoning o.mode = oimSymChoiceLocalLookup o.symChoiceLastPreferred = true o.currentScope = c.currentScope @@ -847,9 +848,6 @@ proc nextOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym = result = nextOverloadIterImports(o, c, n) else: result = nil - if result == nil and o.fallback != nil and o.fallback.id notin o.marked: - result = o.fallback - o.fallback = nil of oimSelfModule: result = nextIdentIter(o.it, c.topLevelScope.symbols) of oimOtherModule: diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index ae1d48d1d9ef0..fdfe3161a892a 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -66,20 +66,22 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule; a = nextOverloadIter(o, c, n) let info = getCallLineInfo(n) if i <= 1 and r != scForceOpen: - # XXX this makes more sense but breaks bootstrapping for now: - # (s.kind notin routineKinds or s.magic != mNone): - # for instance 'nextTry' is both in tables.nim and astalgo.nim ... if not isField or sfGenSym notin s.flags: result = newSymNode(s, info) if r == scClosed or n.kind == nkDotExpr or + # also bind magic procs: (s.magic != mNone and s.kind in routineKinds): markUsed(c, info, s) onUse(info, s) else: - # could maybe instead generate a open symchoice with a preferred sym, - # which the logic for is in the top else branch - # XXX why have this then + # we need a node with a type here so things like default parameters, + # which use semGenericStmt, can infer the parameter type + # from expressions like `false` + # but symchoices having types can mislead the compiler + # instead we allow standalone sym nodes to have nfPreferredSym + # which acts like an open symchoice in initOverloadIter result.flags.incl nfPreferredSym + #result = newTreeIT(nkOpenSymChoice, info, result.typ, result) incl(s.flags, sfUsed) markOwnerModuleAsUsed(c, s) else: From 3c6e780f2ee933599466114dcc7cd5b8bc5affe6 Mon Sep 17 00:00:00 2001 From: metagn <10591326+metagn@users.noreply.github.com> Date: Mon, 25 Dec 2023 23:29:55 +0300 Subject: [PATCH 4/7] try generating a symchoice with type --- compiler/lookups.nim | 35 ----------------------------------- compiler/semexprs.nim | 2 ++ compiler/semtempl.nim | 2 +- 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 3ee7673a0d6e7..c2aa8d8e42489 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -268,41 +268,6 @@ proc cmpScopes*(ctx: PContext, s: PSym): int = else: result = 1 -proc isAmbiguous*(c: PContext, s: PIdent, filter: TSymKinds, sym: var PSym): bool = - result = false - block outer: - for scope in allScopes(c.currentScope): - var ti: TIdentIter - var candidate = initIdentIter(ti, scope.symbols, s) - var scopeHasCandidate = false - while candidate != nil: - if candidate.kind in filter: - if scopeHasCandidate: - # 2 candidates in same scope, ambiguous - return true - else: - scopeHasCandidate = true - sym = candidate - candidate = nextIdentIter(ti, scope.symbols) - if scopeHasCandidate: - # scope had a candidate but wasn't ambiguous - return false - - var importsHaveCandidate = false - var marked = initIntSet() - for im in c.imports.mitems: - for s in symbols(im, marked, s, c.graph): - if s.kind in filter: - if importsHaveCandidate: - # 2 candidates among imports, ambiguous - return true - else: - importsHaveCandidate = true - sym = s - if importsHaveCandidate: - # imports had a candidate but wasn't ambiguous - return false - proc errorSym*(c: PContext, ident: PIdent, info: TLineInfo): PSym = ## creates an error symbol to avoid cascading errors (for IDE support) result = newSym(skError, ident, c.idgen, getCurrOwner(c), info, {}) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 92473d521e285..1dec689a0a355 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -3109,6 +3109,8 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType result = semSymChoice(c, result, flags, expectedType) of nkClosedSymChoice, nkOpenSymChoice: result = semSymChoice(c, result, flags, expectedType) + if isSymChoice(result): + return # don't put nfSem of nkSym: let s = n.sym if nfOpenSym in n.flags: diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index fdfe3161a892a..9342236f29928 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -81,7 +81,7 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule; # instead we allow standalone sym nodes to have nfPreferredSym # which acts like an open symchoice in initOverloadIter result.flags.incl nfPreferredSym - #result = newTreeIT(nkOpenSymChoice, info, result.typ, result) + result = newTreeIT(nkOpenSymChoice, info, result.typ, result) incl(s.flags, sfUsed) markOwnerModuleAsUsed(c, s) else: From 81026afb1f128207dd9bba45526a292394262123 Mon Sep 17 00:00:00 2001 From: metagn <10591326+metagn@users.noreply.github.com> Date: Mon, 25 Dec 2023 23:50:41 +0300 Subject: [PATCH 5/7] walk back generating symchoice, changelog --- changelog.md | 8 ++++++++ compiler/semexprs.nim | 2 -- compiler/semtempl.nim | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index f4a9d627cf671..9b3e33a5d1804 100644 --- a/changelog.md +++ b/changelog.md @@ -14,6 +14,14 @@ ``` will no longer compile. +- In template and generic bodies, for symbols with only 1 overload in scope, + previously the compiler would not allow other overloads in the instantiation + context to be used, which was not the case for 0 or more than 1 overloads. + Now other overloads are allowed with a preference for the original overload + in cases of ambiguity. Some code might need to be changed to use `bind` to + prevent outside overloads from replacing a weaker captured overload. See + [issue #11184](https://github.com/nim-lang/Nim/issues/11184) for more details. + ## Standard library additions and changes [//]: # "Changes:" diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 1dec689a0a355..92473d521e285 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -3109,8 +3109,6 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType result = semSymChoice(c, result, flags, expectedType) of nkClosedSymChoice, nkOpenSymChoice: result = semSymChoice(c, result, flags, expectedType) - if isSymChoice(result): - return # don't put nfSem of nkSym: let s = n.sym if nfOpenSym in n.flags: diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 9342236f29928..fdfe3161a892a 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -81,7 +81,7 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule; # instead we allow standalone sym nodes to have nfPreferredSym # which acts like an open symchoice in initOverloadIter result.flags.incl nfPreferredSym - result = newTreeIT(nkOpenSymChoice, info, result.typ, result) + #result = newTreeIT(nkOpenSymChoice, info, result.typ, result) incl(s.flags, sfUsed) markOwnerModuleAsUsed(c, s) else: From 3bd469f5a940bc143b5b38c030fe1cf1ceb473d4 Mon Sep 17 00:00:00 2001 From: metagn <10591326+metagn@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:07:15 +0300 Subject: [PATCH 6/7] rebase, add test for #15650, will try removing finishOperand after --- compiler/semexprs.nim | 4 ++-- tests/template/tbaddeprecated.nim | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 tests/template/tbaddeprecated.nim diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 92473d521e285..49c2e67b93d36 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -141,9 +141,9 @@ proc resolveSymChoice(c: PContext, n: var PNode, flags: TExprFlags = {}, expecte if isSymChoice(n) and efAllowSymChoice notin flags: # some contexts might want sym choices preserved for later disambiguation # in general though they are ambiguous - let first = n[0].sym + let first = n[0] if nfPreferredSym in first.flags: - n = n[0] + n = first proc semSymChoice(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType = nil): PNode = result = n diff --git a/tests/template/tbaddeprecated.nim b/tests/template/tbaddeprecated.nim new file mode 100644 index 0000000000000..1d96982c8fad1 --- /dev/null +++ b/tests/template/tbaddeprecated.nim @@ -0,0 +1,13 @@ +# issue #15650 + +{.warningAsError[Deprecated]: on.} + +proc bar() {.deprecated.} = discard + +template foo() = + when false: + bar() + else: + discard + +foo() From 6325b707de9879293c0dc96ddc50b812af6d5b73 Mon Sep 17 00:00:00 2001 From: metagn <10591326+metagn@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:58:38 +0300 Subject: [PATCH 7/7] walk back finishOperand, add small sanity test --- compiler/sigmatch.nim | 9 +-------- tests/enum/tcrossmodule.nim | 2 ++ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 1ac835c921c3a..9d2a611309d13 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -2469,13 +2469,6 @@ proc prepareOperand(c: PContext; a: PNode): PNode = result = a considerGenSyms(c, result) -proc finishOperand(c: PContext; a: PNode): PNode = - if a.typ.isNil: - result = c.semExprWithType(c, a, {efOperand, efAllowSymChoice}) - else: - result = a - considerGenSyms(c, result) - proc prepareNamedParam(a: PNode; c: PContext) = if a[0].kind != nkIdent: var info = a[0].info @@ -2717,7 +2710,7 @@ proc semFinishOperands*(c: PContext, n: PNode) = # this needs to be called to ensure that after overloading resolution every # argument has been sem'checked: for i in 1..