summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2024-02-01 18:31:42 -0500
committerKevin Newton <kddnewton@gmail.com>2024-02-02 18:50:41 -0500
commit90ae8eaecae00eabd2d7dc8ec7ee1afc53a6bd9d (patch)
tree8f4f89624ae3d966c4305322f166501d74171ca5 /test
parent5d646fa136131c18a7a432486c65438abe9790e2 (diff)
[PRISM] Fix numbered parameters stealing local names
Previously, the local index of numbered parameters were assigned to names of regular locals, making it hard to read both of them. Use proper `_[1-9]` numbered parameters. This fixes `test_shapes.rb`. Also, properly mark the iseq as having lead parameters.
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_compile_prism.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index a66213c442..b9c8d1bb5b 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -1721,6 +1721,11 @@ a
assert_prism_eval("def self.foo(a:, b: 2, c: '3'.to_i); [a, b, c]; end; foo(a: 1)")
end
+ def test_numbered_params
+ assert_prism_eval("[1, 2, 3].then { _3 }")
+ assert_prism_eval("1.then { one = 1; one + _1 }")
+ end
+
def test_rescue_with_ensure
assert_prism_eval(<<-CODE)
begin