Skip to content

Commit

Permalink
semProcAux hasError cover fixupInstantiatedSymbols
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 committed Oct 3, 2023
1 parent 0e09df4 commit cf0a45a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions compiler/sem/seminst.nim
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,20 @@ proc instantiateBody(c: PContext, n, params: PNode, result, orig: PSym) =
trackProc(c, result, result.ast[bodyPos])
dec c.inGenericInst

proc fixupInstantiatedSymbols(c: PContext, s: PSym) =
proc fixupInstantiatedSymbols(c: PContext, s: PSym): bool =
result = true
for i in 0..<c.generics.len:
if c.generics[i].genericSym.id == s.id:
var oldPrc = c.generics[i].inst.sym
var
oldPrc = c.generics[i].inst.sym
n = oldPrc.ast
if n.kind == nkError:
result = false
continue
pushProcCon(c, oldPrc)
pushOwner(c, oldPrc)
pushInfoContext(c.config, oldPrc.info)
openScope(c)
var n = oldPrc.ast
n[bodyPos] = copyTree(getBody(c.graph, s))
instantiateBody(c, n, oldPrc.typ.n, oldPrc, s)
closeScope(c)
Expand Down
3 changes: 2 additions & 1 deletion compiler/sem/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2810,7 +2810,8 @@ proc semProcAux(c: PContext, n: PNode, validPragmas: TSpecialWords,
result[bodyPos] = semGenericStmt(c, n[bodyPos])
closeScope(c)
if s.magic == mNone:
fixupInstantiatedSymbols(c, s)
if not fixupInstantiatedSymbols(c, s):
hasError = true
if s.kind == skMethod: semMethodPrototype(c, s, result)
popProcCon(c)
else:
Expand Down

0 comments on commit cf0a45a

Please sign in to comment.