fixes #4551
This commit is contained in:
parent
f1092512e3
commit
440ed8eb68
2 changed files with 16 additions and 0 deletions
|
|
@ -1980,6 +1980,9 @@ proc exprComplexConst(p: BProc, n: PNode, d: var TLoc) =
|
||||||
fillLoc(d, locData, t, tmp, OnStatic)
|
fillLoc(d, locData, t, tmp, OnStatic)
|
||||||
else:
|
else:
|
||||||
putDataIntoDest(p, d, t, tmp)
|
putDataIntoDest(p, d, t, tmp)
|
||||||
|
# This fixes bug #4551, but we really need better dataflow
|
||||||
|
# analysis to make this 100% safe.
|
||||||
|
d.s = OnStatic
|
||||||
|
|
||||||
proc expr(p: BProc, n: PNode, d: var TLoc) =
|
proc expr(p: BProc, n: PNode, d: var TLoc) =
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
|
||||||
13
tests/ccgbugs/tcapture_static.nim
Normal file
13
tests/ccgbugs/tcapture_static.nim
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
discard """
|
||||||
|
output: '''hi'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #4551
|
||||||
|
|
||||||
|
proc foo() =
|
||||||
|
let arr = ["hi"]
|
||||||
|
for i, v in arr:
|
||||||
|
let bar = proc =
|
||||||
|
echo v
|
||||||
|
bar()
|
||||||
|
foo()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue