diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index f57a8c90be1cd..7aa9565ec0e04 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -1324,8 +1324,8 @@ `(tryfinally ,(if (not (eq? catchb 'false)) `(try ,tryb ,var ,catchb) - tryb) - ,finalb)))) + `(scope-block ,tryb)) + (scope-block ,finalb))))) ((length= e 4) (expand-forms (if (and (symbol-like? var) (not (eq? var 'false))) @@ -3481,7 +3481,7 @@ f(x) = yt(x) (convert-for-type-decl y rett) y)) (if (> handler-level 0) - (let ((tmp (cond ((or (simple-atom? x) (ssavalue? x) (equal? x '(null))) + (let ((tmp (cond ((or (simple-atom? x) (equal? x '(null))) #f) (finally-handler (new-mutable-var)) (else (make-ssavalue))))) diff --git a/test/core.jl b/test/core.jl index 81de6b9c41e1b..4d8b1311f0707 100644 --- a/test/core.jl +++ b/test/core.jl @@ -867,6 +867,20 @@ function test12806() end @test test12806() == (true, true, false, [1]) +# issue #24331 +try + c24331 = 1 +finally +end +@test !isdefined(@__MODULE__, :c24331) +function f24331() + try + x = [2] + finally + end +end +@test f24331() == [2] + # finalizers let A = [1] local x = 0