Skip to content

Commit 2b0fe93

Browse files
committed
lowering: preserve handler order in (pop-handler-list ...)
This was reversing the list of handlers on accident.
1 parent 2943833 commit 2b0fe93

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/julia-syntax.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4443,8 +4443,8 @@ f(x) = yt(x)
44434443
(error "Attempt to jump into catch block")
44444444
(error (string "cannot goto label \"" lab "\" inside try/catch block"))))
44454445
(if (eq? (cdr s) dest-tokens)
4446-
(cons (car s) l)
4447-
(loop (cdr s) (cons (car s) l))))))
4446+
(append l (car s))
4447+
(loop (cdr s) (append l (car s)))))))
44484448
(define (emit-return tail x)
44494449
(define (emit- x)
44504450
(let* ((tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)

test/syntax.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3865,6 +3865,29 @@ end
38653865
end
38663866
end
38673867

3868+
let src = Meta.@lower let
3869+
try
3870+
try
3871+
return 1
3872+
catch
3873+
end
3874+
finally
3875+
nothing
3876+
end
3877+
end
3878+
code = src.args[1].code
3879+
for stmt in code
3880+
if Meta.isexpr(stmt, :leave) && length(stmt.args) > 1
3881+
# Expr(:leave, ...) should list the arguments to pop from
3882+
# inner-most scope to outer-most
3883+
@test issorted(Int[
3884+
(arg::Core.SSAValue).id
3885+
for arg in stmt.args
3886+
]; rev=true)
3887+
end
3888+
end
3889+
end
3890+
38683891
# Test that globals can be `using`'d even if they are not yet defined
38693892
module UndefGlobal54954
38703893
global theglobal54954::Int

0 commit comments

Comments
 (0)