parent
f760bc243b
commit
fc858927f0
4 changed files with 8 additions and 6 deletions
|
|
@ -1359,9 +1359,9 @@ 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 skProc, skTemplate, skMacro, skIterator, skMethod, skConverter:
|
||||||
result = s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty
|
result = sfFromGeneric in s.flags
|
||||||
else: nil
|
else: nil
|
||||||
|
|
||||||
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}
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,9 @@ proc interestingVar(s: PSym): bool {.inline.} =
|
||||||
proc semCaptureSym*(s, owner: PSym) =
|
proc semCaptureSym*(s, owner: PSym) =
|
||||||
if interestingVar(s) and owner.id != s.owner.id and s.kind != skResult:
|
if interestingVar(s) and owner.id != s.owner.id and s.kind != skResult:
|
||||||
if owner.typ != nil and not isGenericRoutine(owner):
|
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
|
owner.typ.callConv = ccClosure
|
||||||
#echo "semCaptureSym ", owner.name.s, owner.id, " ", s.name.s, s.id
|
#echo "semCaptureSym ", owner.name.s, owner.id, " ", s.name.s, s.id
|
||||||
# since the analysis is not entirely correct, we don't set 'tfCapturesEnv'
|
# since the analysis is not entirely correct, we don't set 'tfCapturesEnv'
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,6 @@ proc fixupInstantiatedSymbols(c: PContext, s: PSym) =
|
||||||
openScope(c)
|
openScope(c)
|
||||||
var n = oldPrc.ast
|
var n = oldPrc.ast
|
||||||
n.sons[bodyPos] = copyTree(s.getBody)
|
n.sons[bodyPos] = copyTree(s.getBody)
|
||||||
if n.sons[paramsPos].kind != nkEmpty:
|
|
||||||
addParams(c, oldPrc.typ.n, oldPrc.kind)
|
|
||||||
instantiateBody(c, n, oldPrc)
|
instantiateBody(c, n, oldPrc)
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
popInfoContext()
|
popInfoContext()
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
discard """
|
discard """
|
||||||
output: "1.0000000000000000e+00 10"
|
output: "1.1000000000000001e+00 11"
|
||||||
ccodecheck: "!@'ClEnv'"
|
ccodecheck: "!@'ClEnv'"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -8,5 +8,6 @@ proc p[T](a, b: T): T
|
||||||
echo p(0.9, 0.1), " ", p(9, 1)
|
echo p(0.9, 0.1), " ", p(9, 1)
|
||||||
|
|
||||||
proc p[T](a, b: T): T =
|
proc p[T](a, b: T): T =
|
||||||
result = a + b
|
let c = b
|
||||||
|
result = a + b + c
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue