Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect path taken when rescue nested inside a rescue/else #1201

Merged
merged 6 commits into from
Sep 4, 2023

Conversation

seven1m
Copy link
Member

@seven1m seven1m commented Sep 4, 2023

This is a compiler bug. There is something odd going on with the LocalJumpError caused by a return inside a block.

When the return is not followed, GlobalEnv::rescued gets set to false, and that causes the outer rescue/else to think that the else block should run.

This makes me think that we either cannot use a global to track rescued, or that we have to put it back when checking for LocalJumpError.

Turns out this can be triggered much more simply, and the above LocalJumpError explanation is but a symptom of this simpler problem. You cannot nest a rescue inside a rescue/else and get the correct result reliably. 🤦‍♂️

@seven1m seven1m self-assigned this Sep 4, 2023
@seven1m seven1m changed the title Add failing test for rescue/else with LocalJumpError Add failing test for rescue/else containing a nested rescue Sep 4, 2023
@seven1m seven1m force-pushed the rescue-else-break-error branch from f525281 to cd5975e Compare September 4, 2023 19:39
@seven1m seven1m changed the title Add failing test for rescue/else containing a nested rescue Fix incorrect path taken when rescue nested inside a rescue/else Sep 4, 2023
@seven1m seven1m marked this pull request as ready for review September 4, 2023 20:39
@seven1m seven1m merged commit 2bdc967 into master Sep 4, 2023
10 checks passed
@seven1m seven1m deleted the rescue-else-break-error branch September 4, 2023 21:27
seven1m added a commit that referenced this pull request Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant