Skip to content

Commit

Permalink
walk back more, disable seemingly unnecessary stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Sep 29, 2023
1 parent e194df3 commit d76ca10
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
10 changes: 5 additions & 5 deletions compiler/lookups.nim
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ proc lookUp*(c: PContext, n: PNode): PSym =
if result == nil: result = errorUndeclaredIdentifierHint(c, n, n.ident)
of nkSym:
result = n.sym
if nfOpenSym in n.flags:
if false and nfOpenSym in n.flags:
let alt = searchInScopes(c, result.name, amb)
if alt != nil and alt != result and not amb:
if alt != nil and alt != result and not amb and alt.owner == c.p.owner:
result = alt
of nkAccQuoted:
var ident = considerQuotedIdent(c, n)
Expand Down Expand Up @@ -650,10 +650,10 @@ proc qualifiedLookUp*(c: PContext, n: PNode, flags: set[TLookupFlag]): PSym =
c.isAmbiguous = amb
of nkSym:
result = n.sym
if nfOpenSym in n.flags:
if false and nfOpenSym in n.flags:
var amb = false
let alt = searchInScopes(c, result.name, amb)
if alt != nil and alt != result and not amb:
if alt != nil and alt != result and not amb and alt.owner == c.p.owner:
result = alt
of nkDotExpr:
result = nil
Expand Down Expand Up @@ -721,7 +721,7 @@ proc initOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym =
return nil

of nkSym:
if nfOpenSym notin n.flags:
if true or nfOpenSym notin n.flags:
result = n.sym
if nfPreferredSym in n.flags:
o.mode = oimSymChoiceLocalLookup
Expand Down
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3071,7 +3071,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType: PType
let id = newIdentNode(s.name, n.info)
c.isAmbiguous = false
let s2 = qualifiedLookUp(c, id, {})
if s2 != nil and s2 != s and not c.isAmbiguous:
if s2 != nil and s2 != s and not c.isAmbiguous and s2.owner == c.p.owner:
result = semExpr(c, id, flags, expectedType)
return
# because of the changed symbol binding, this does not mean that we
Expand Down
11 changes: 10 additions & 1 deletion compiler/semgnrc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,16 @@ proc semGenericStmt(c: PContext, n: PNode,
var dummy: bool
result = fuzzyLookup(c, n, flags, ctx, dummy)
of nkSym:
let a = n.sym
var a = n.sym
if nfOpenSym in n.flags:
let id = newIdentNode(a.name, n.info)
c.isAmbiguous = false
let s2 = qualifiedLookUp(c, id, {})
if s2 != nil and s2 != a and not c.isAmbiguous and s2.owner == c.p.owner:
n.sym = s2
a = s2
if withinMixin notin flags:
n.flags.excl nfOpenSym
let b = getGenSym(c, a)
if b != a: n.sym = b
of nkEmpty, succ(nkSym)..nkNilLit, nkComesFrom:
Expand Down
8 changes: 8 additions & 0 deletions compiler/semtempl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,14 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
inc c.noGenSym
result[1] = semTemplBody(c, n[1])
dec c.noGenSym
if result[1].kind == nkSym and result[1].sym.kind in routineKinds:
# prevent `dotTransformation` from rewriting this node to `nkIdent`
# by making it a symchoice
# in generics this becomes `nkClosedSymChoice` but this breaks code
# as the old behavior here was that this became `nkIdent`
var choice = newNodeIT(nkOpenSymChoice, n[1].info, newTypeS(tyNone, c.c))
choice.add result[1]
result[1] = choice
else:
result = semTemplBodySons(c, n)
of nkExprColonExpr, nkExprEqExpr:
Expand Down

0 comments on commit d76ca10

Please sign in to comment.