mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 03:32:32 +00:00
check the owners of generic instantiations properly and fix tinvalidclosure
This commit is contained in:
@@ -792,6 +792,7 @@ const
|
||||
nkStrKinds* = {nkStrLit..nkTripleStrLit}
|
||||
|
||||
skLocalVars* = {skVar, skLet, skForVar, skParam, skResult}
|
||||
skProcKinds* = {skProc, skTemplate, skMacro, skIterator, skMethod, skConverter}
|
||||
|
||||
lfFullExternalName* = lfParamCopy # \
|
||||
# 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 =
|
||||
case s.kind
|
||||
of skProc, skTemplate, skMacro, skIterator, skMethod, skConverter:
|
||||
of skProcKinds:
|
||||
result = sfFromGeneric in s.flags or
|
||||
(s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty)
|
||||
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.} =
|
||||
result = s.kind in {skProc, skTemplate, skMacro, skIterator, skMethod,
|
||||
skConverter}
|
||||
|
||||
@@ -219,8 +219,8 @@ proc getHiddenParam(routine: PSym): PSym =
|
||||
result = hidden.sym
|
||||
|
||||
proc isInnerProc(s, outerProc: PSym): bool {.inline.} =
|
||||
result = s.kind in {skProc, skMethod, skConverter} and
|
||||
s.owner == outerProc
|
||||
result = s.kind in {skProc, skMethod, skConverter} and
|
||||
s.skipGenericOwner == outerProc
|
||||
#s.typ.callConv == ccClosure
|
||||
|
||||
proc addClosureParam(i: PInnerContext, e: PEnv) =
|
||||
|
||||
Reference in New Issue
Block a user