Skip to content

[JuliaLowering] Fix try-finally token stack handling#61523

Closed
topolarity wants to merge 1 commit intoJuliaLang:masterfrom
topolarity:ct/JL-fix-try-finally
Closed

[JuliaLowering] Fix try-finally token stack handling#61523
topolarity wants to merge 1 commit intoJuliaLang:masterfrom
topolarity:ct/JL-fix-try-finally

Conversation

@topolarity
Copy link
Copy Markdown
Member

@topolarity topolarity commented Apr 7, 2026

The token stack of the handler is just outside of the try-finally, so the right logic is to check if we jump to that level or higher.

We could probably use more test coverage for this code, but let's do a spot fix for now.

Resolves JuliaLang/JuliaLowering.jl#171.

The token stack of the `handler` is just outside of the `try-finally` so
we need to check if we jump to that level or higher.
@topolarity topolarity requested a review from mlechu April 7, 2026 15:12
@topolarity topolarity added bugfix This change fixes an existing bug JuliaLowering labels Apr 7, 2026
@topolarity
Copy link
Copy Markdown
Member Author

Closing in favor of #61525

@topolarity topolarity closed this Apr 7, 2026
topolarity pushed a commit that referenced this pull request Apr 9, 2026
Alternative to #61523, fix
JuliaLang/JuliaLowering.jl#171.

Push to `ctx.handler_token_stack` before construction of the
`FinallyHandler`, since the `JumpTarget` constructor needs it. The extra
entry is ignored in `enter_finally_block`'s call to
`emit_leave_handler`, but not in the one in `emit_break`. These changes
should directly match flisp.

I think we're still missing some `pop_exception`s compared to flisp, but
wanted to get this PR up given the other one. As noted in the tests, I
need to port #55876, which
duplicates the finally block and only adds `pop_exception` to one copy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This change fixes an existing bug JuliaLowering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

continue inside for does not respect finally

1 participant