Skip to content

Commit

Permalink
actually intentional behavior for semtempl
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Sep 23, 2023
1 parent fef14fa commit 16a4350
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ proc semExprWithType(c: PContext, n: PNode, flags: TExprFlags = {}, expectedType
result.typ = errorType(c)
elif {efTypeAllowed, efOperand} * flags != {} and
result.typ.kind == tyProc and
containsGenericType(result.typ):
hasUnresolvedParams(result, {}):
# mirrored with semOperand but only on efTypeAllowed
let owner = result.typ.owner
let err =
Expand Down
2 changes: 1 addition & 1 deletion compiler/sempass2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ proc isTrival(caller: PNode): bool {.inline.} =
proc trackOperandForIndirectCall(tracked: PEffects, n: PNode, formals: PType; argIndex: int; caller: PNode) =
let a = skipConvCastAndClosure(n)
let op = a.typ
let param = if formals != nil and argIndex < formals.len and formals.n != nil: formals.n[argIndex].sym else: nil
let param = if formals != nil and formals.n != nil and argIndex < formals.n.len: formals.n[argIndex].sym else: nil
# assume indirect calls are taken here:
if op != nil and op.kind == tyProc and n.skipConv.kind != nkNilLit and
not isTrival(caller) and
Expand Down
20 changes: 13 additions & 7 deletions compiler/semtempl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule;
result.add newSymNode(a, info)
onUse(info, a)
a = nextOverloadIter(o, c, n)
if firstPreferred:
if r != scForceOpen and firstPreferred:
result[0].flags.incl nfPreferredSym

proc semBindStmt(c: PContext, n: PNode, toBind: var IntSet): PNode =
Expand Down Expand Up @@ -256,24 +256,30 @@ proc semTemplSymbol(c: PContext, n: PNode, s: PSym; isField: bool): PNode =
result.typ = nil
of skGenericParam:
if isField and sfGenSym in s.flags: result = n
else: result = newSymNodeTypeDesc(s, c.idgen, n.info)
else:
result = newSymNodeTypeDesc(s, c.idgen, n.info)
result.flags.incl nfOpenSym
result.typ = nil
of skParam:
result = n
of skType:
if isField and sfGenSym in s.flags: result = n
else: result = newSymNodeTypeDesc(s, c.idgen, n.info)
else:
result = newSymNodeTypeDesc(s, c.idgen, n.info)
result.flags.incl nfOpenSym
result.typ = nil
else:
if isField and sfGenSym in s.flags: result = n
else: result = newSymNode(s, n.info)
else:
result = newSymNode(s, n.info)
result.flags.incl nfOpenSym
result.typ = nil
# Issue #12832
when defined(nimsuggest):
suggestSym(c.graph, n.info, s, c.graph.usageSym, false)
# field access (dot expr) will be handled by builtinFieldAccess
if not isField:
styleCheckUse(c, n.info, s)
if result.kind == nkSym:
result.flags.incl nfOpenSym
result.typ = nil

proc semRoutineInTemplName(c: var TemplCtx, n: PNode): PNode =
result = n
Expand Down

0 comments on commit 16a4350

Please sign in to comment.