Skip to content

Commit

Permalink
don't treat template/macro/module as overloaded for opensym
Browse files Browse the repository at this point in the history
actually fixes nim-lang#23865 following up nim-lang#23873
  • Loading branch information
metagn committed Aug 11, 2024
1 parent c97a20c commit ddff0e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ proc semOpenSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags, expectedType:
# enough to replace the original
# for `nkOpenSymChoice`, the first found symbol must be non-overloadable,
# since otherwise we have to use regular `nkOpenSymChoice` functionality
# but of the overloadable sym kinds, semExpr does not handle skModule, skMacro, skTemplate
# as overloaded in the case where `nkIdent` finds them first
if s2 != nil and not c.isAmbiguous and
((s == nil and s2.kind notin OverloadableSyms) or
((s == nil and s2.kind notin OverloadableSyms-{skModule, skMacro, skTemplate}) or
(s != nil and s2 != s)):
# only consider symbols defined under current proc:
var o = s2.owner
Expand Down
2 changes: 1 addition & 1 deletion compiler/semgnrc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ proc semGenericStmtSymbol(c: PContext, n: PNode, s: PSym,
result = symChoice(c, n, s, scOpen)
if canOpenSym(s):
result.flags.incl nfOpenSym
if result.kind == nkSym: result.typ = nil
result.typ = nil
case s.kind
of skUnknown:
# Introduced in this pass! Leave it as an identifier.
Expand Down
2 changes: 1 addition & 1 deletion tests/generics/tmacroinjectedsym.nim
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ block: # issue #23865
let x = f().valueOr:
return $error
"ok"
doAssert g(int) == "error"
doAssert g(int) == "f"

0 comments on commit ddff0e8

Please sign in to comment.