Skip to content

Commit

Permalink
lowering: preserve handler order in (pop-handler-list ...)
Browse files Browse the repository at this point in the history
This was reversing the list of handlers on accident.
  • Loading branch information
topolarity committed Sep 25, 2024
1 parent 2943833 commit 2b0fe93
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4443,8 +4443,8 @@ f(x) = yt(x)
(error "Attempt to jump into catch block")
(error (string "cannot goto label \"" lab "\" inside try/catch block"))))
(if (eq? (cdr s) dest-tokens)
(cons (car s) l)
(loop (cdr s) (cons (car s) l))))))
(append l (car s))
(loop (cdr s) (append l (car s)))))))
(define (emit-return tail x)
(define (emit- x)
(let* ((tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)
Expand Down
23 changes: 23 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3865,6 +3865,29 @@ end
end
end

let src = Meta.@lower let
try
try
return 1
catch
end
finally
nothing
end
end
code = src.args[1].code
for stmt in code
if Meta.isexpr(stmt, :leave) && length(stmt.args) > 1
# Expr(:leave, ...) should list the arguments to pop from
# inner-most scope to outer-most
@test issorted(Int[
(arg::Core.SSAValue).id
for arg in stmt.args
]; rev=true)
end
end
end

# Test that globals can be `using`'d even if they are not yet defined
module UndefGlobal54954
global theglobal54954::Int
Expand Down

0 comments on commit 2b0fe93

Please sign in to comment.