mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-04 02:44:44 +00:00
fixes #4551
This commit is contained in:
@@ -1980,6 +1980,9 @@ proc exprComplexConst(p: BProc, n: PNode, d: var TLoc) =
|
||||
fillLoc(d, locData, t, tmp, OnStatic)
|
||||
else:
|
||||
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) =
|
||||
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()
|
||||
Reference in New Issue
Block a user