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

[PRISM] Fix segv with regex once flag #9207

Merged
merged 1 commit into from Dec 12, 2023

Conversation

eileencodes
Copy link
Contributor

When you have an interpolated regex with a once flag and local variable is outside the block created by the once flag, Prism would see a segv. This is because it was not taking the depth into account.

To fix this, we need to add 1 to the local_depth_offset on the scope.

Fixes: ruby/prism#2047

cc/ @jemmaissroff @tenderlove

When you have an interpolated regex with a `once` flag and local
variable is outside the block created by the `once` flag, Prism would
see a segv. This is because it was not taking the depth into account.

To fix this, we need to add 1 to the `local_depth_offset` on the
`scope`.

Fixes: ruby/prism#2047
Copy link
Contributor

@jemmaissroff jemmaissroff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@jemmaissroff jemmaissroff enabled auto-merge (rebase) December 12, 2023 20:09
@jemmaissroff jemmaissroff merged commit a652634 into ruby:master Dec 12, 2023
96 of 98 checks passed
@eileencodes eileencodes deleted the prism-fix-segv-for-once branch December 12, 2023 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants