From a6526342f3fbd94abc44cc4e99eda0943a61271f Mon Sep 17 00:00:00 2001 From: eileencodes Date: Tue, 12 Dec 2023 13:44:33 -0500 Subject: [PRISM] Fix segv with regex once flag 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 --- test/ruby/test_compile_prism.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'test/ruby') diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index e95baf5d5c..0409fc3e46 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -601,6 +601,7 @@ module Prism assert_prism_eval('/pit/ne') assert_prism_eval('2.times.map { /#{1}/o }') + assert_prism_eval('2.times.map { foo = 1; /#{foo}/o }') end def test_StringNode -- cgit v1.2.3