diff options
| author | Aaron Patterson <tenderlove@ruby-lang.org> | 2024-01-23 12:11:21 -0800 |
|---|---|---|
| committer | Aaron Patterson <aaron.patterson@gmail.com> | 2024-01-24 09:40:30 -0800 |
| commit | 7a33a1aee2739598fc5b17cfd6f31e20769fee28 (patch) | |
| tree | d7bef155ef28aafdd0bee11a97a2975d04b5b7db /test/ruby | |
| parent | 927928badb1a53aae6b29e65627720d7cb6cfdd7 (diff) | |
Insert all locals in the locals index table
Prism provides an index (local_body_index) which is supposed to point at
the start of locals declared in the method body. Prism assumed that
method body locals would only occur _after_ parameter names.
Unfortunately this assumption is not correct, which meant that we would
in some cases not insert all locals in the local table. This commit
iterates over locals a second time, inserting any that didn't get
inserted on the first pass.
Fixes: https://github.com/ruby/prism/issues/2245
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 5425f2c730..f2a01c9684 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1545,6 +1545,10 @@ a CODE end + def test_locals_in_parameters + assert_prism_eval("def self.m(a = b = c = 1); [a, b, c]; end; self.m") + end + def test_trailing_comma_on_block assert_prism_eval("def self.m; yield [:ok]; end; m {|v0,| v0 }") end |
