check the owners of generic instantiations properly and fix tinvalidclosure
This commit is contained in:
parent
b01d9b6181
commit
4980ef85e2
2 changed files with 12 additions and 3 deletions
|
|
@ -792,6 +792,7 @@ const
|
||||||
nkStrKinds* = {nkStrLit..nkTripleStrLit}
|
nkStrKinds* = {nkStrLit..nkTripleStrLit}
|
||||||
|
|
||||||
skLocalVars* = {skVar, skLet, skForVar, skParam, skResult}
|
skLocalVars* = {skVar, skLet, skForVar, skParam, skResult}
|
||||||
|
skProcKinds* = {skProc, skTemplate, skMacro, skIterator, skMethod, skConverter}
|
||||||
|
|
||||||
lfFullExternalName* = lfParamCopy # \
|
lfFullExternalName* = lfParamCopy # \
|
||||||
# only used when 'gCmd == cmdPretty': Indicates that the symbol has been
|
# only used when 'gCmd == cmdPretty': Indicates that the symbol has been
|
||||||
|
|
@ -1358,11 +1359,19 @@ proc getStrOrChar*(a: PNode): string =
|
||||||
|
|
||||||
proc isGenericRoutine*(s: PSym): bool =
|
proc isGenericRoutine*(s: PSym): bool =
|
||||||
case s.kind
|
case s.kind
|
||||||
of skProc, skTemplate, skMacro, skIterator, skMethod, skConverter:
|
of skProcKinds:
|
||||||
result = sfFromGeneric in s.flags or
|
result = sfFromGeneric in s.flags or
|
||||||
(s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty)
|
(s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty)
|
||||||
else: nil
|
else: nil
|
||||||
|
|
||||||
|
proc skipGenericOwner*(s: PSym): PSym =
|
||||||
|
InternalAssert s.kind in skProcKinds
|
||||||
|
## Generic instantiations are owned by their originating generic
|
||||||
|
## symbol. This proc skips such owners and goes straigh to the owner
|
||||||
|
## of the generic itself (the module or the enclosing proc).
|
||||||
|
result = if sfFromGeneric in s.flags: s.owner.owner
|
||||||
|
else: s.owner
|
||||||
|
|
||||||
proc isRoutine*(s: PSym): bool {.inline.} =
|
proc isRoutine*(s: PSym): bool {.inline.} =
|
||||||
result = s.kind in {skProc, skTemplate, skMacro, skIterator, skMethod,
|
result = s.kind in {skProc, skTemplate, skMacro, skIterator, skMethod,
|
||||||
skConverter}
|
skConverter}
|
||||||
|
|
|
||||||
|
|
@ -219,8 +219,8 @@ proc getHiddenParam(routine: PSym): PSym =
|
||||||
result = hidden.sym
|
result = hidden.sym
|
||||||
|
|
||||||
proc isInnerProc(s, outerProc: PSym): bool {.inline.} =
|
proc isInnerProc(s, outerProc: PSym): bool {.inline.} =
|
||||||
result = s.kind in {skProc, skMethod, skConverter} and
|
result = s.kind in {skProc, skMethod, skConverter} and
|
||||||
s.owner == outerProc
|
s.skipGenericOwner == outerProc
|
||||||
#s.typ.callConv == ccClosure
|
#s.typ.callConv == ccClosure
|
||||||
|
|
||||||
proc addClosureParam(i: PInnerContext, e: PEnv) =
|
proc addClosureParam(i: PInnerContext, e: PEnv) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue