parent
9c45e33d8c
commit
e3f93241c3
4 changed files with 6 additions and 8 deletions
|
|
@ -1285,9 +1285,9 @@ proc getStrOrChar*(a: PNode): string =
|
|||
proc isGenericRoutine*(s: PSym): bool =
|
||||
case s.kind
|
||||
of skProc, skTemplate, skMacro, skIterator, skMethod, skConverter:
|
||||
result = sfFromGeneric in s.flags
|
||||
result = s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty
|
||||
else: nil
|
||||
|
||||
|
||||
proc isRoutine*(s: PSym): bool {.inline.} =
|
||||
result = s.kind in {skProc, skTemplate, skMacro, skIterator, skMethod,
|
||||
skConverter}
|
||||
|
|
|
|||
|
|
@ -288,9 +288,6 @@ proc interestingVar(s: PSym): bool {.inline.} =
|
|||
proc semCaptureSym*(s, owner: PSym) =
|
||||
if interestingVar(s) and owner.id != s.owner.id and s.kind != skResult:
|
||||
if owner.typ != nil and not isGenericRoutine(owner):
|
||||
# XXX: is this really safe?
|
||||
# if we capture a var from another generic routine,
|
||||
# it won't be consider captured.
|
||||
owner.typ.callConv = ccClosure
|
||||
#echo "semCaptureSym ", owner.name.s, owner.id, " ", s.name.s, s.id
|
||||
# since the analysis is not entirely correct, we don't set 'tfCapturesEnv'
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ proc fixupInstantiatedSymbols(c: PContext, s: PSym) =
|
|||
openScope(c)
|
||||
var n = oldPrc.ast
|
||||
n.sons[bodyPos] = copyTree(s.getBody)
|
||||
if n.sons[paramsPos].kind != nkEmpty:
|
||||
addParams(c, oldPrc.typ.n, oldPrc.kind)
|
||||
instantiateBody(c, n, oldPrc)
|
||||
closeScope(c)
|
||||
popInfoContext()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue