Skip to content

Commit 8a4f20b

Browse files
authored
fix #30048, lowering gc_preserve of closure variables (#30051)
1 parent ff74f6b commit 8a4f20b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/julia-syntax.scm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,8 +3893,9 @@ f(x) = yt(x)
38933893
'(null))
38943894

38953895
((gc_preserve_begin)
3896-
(let ((s (make-ssavalue)))
3897-
(emit `(= ,s ,e))
3896+
(let ((s (make-ssavalue))
3897+
(args (compile-args (cdr e) break-labels linearize-args)))
3898+
(emit `(= ,s ,(cons (car e) args)))
38983899
s))
38993900

39003901
;; metadata expressions

test/syntax.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,6 +1736,21 @@ end
17361736
# we don't parse chains of these since the associativity and meaning aren't clear
17371737
@test_throws ParseError Meta.parse("1..2..3")
17381738

1739+
# issue #30048
1740+
@test Meta.isexpr(Meta.lower(@__MODULE__, :(for a in b
1741+
c = try
1742+
try
1743+
d() do
1744+
if GC.@preserve c begin
1745+
end
1746+
end
1747+
end
1748+
finally
1749+
end
1750+
finally
1751+
end
1752+
end)), :thunk)
1753+
17391754
# issue #28506
17401755
@test Meta.isexpr(Meta.parse("1,"), :incomplete)
17411756
@test Meta.isexpr(Meta.parse("1, "), :incomplete)

0 commit comments

Comments
 (0)