aboutsummaryrefslogtreecommitdiffstats
path: root/test/prism/errors_test.rb
diff options
context:
space:
mode:
authorHaldun Bayhantopcu <haldun@github.com>2023-10-05 13:48:50 +0200
committergit <svn-admin@ruby-lang.org>2023-10-05 16:35:45 +0000
commit8d8fe5435567553a1b3381103585ed3214fbee81 (patch)
tree405ba4cd22ba14b5b8f519226dc0cccf47d60713 /test/prism/errors_test.rb
parent38cb92a00c65526898ec4d7949e7d0f9b75666a5 (diff)
downloadruby-8d8fe5435567553a1b3381103585ed3214fbee81.tar.gz
[ruby/prism] Check for duplicate parameter names in destructured params
https://github.com/ruby/prism/commit/c3438aabea
Diffstat (limited to 'test/prism/errors_test.rb')
-rw-r--r--test/prism/errors_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index b2a6bc8d13..d383c66f41 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -1380,6 +1380,15 @@ module Prism
]
end
+ def test_repeated_parameter_name_in_destructured_params
+ source = "def f(a, (b, (a))); end"
+ # In Ruby 3.0.x, `Ripper.sexp_raw` does not return `nil` for this case.
+ compare_ripper = RUBY_ENGINE == "ruby" && (RUBY_VERSION.split('.').map { |x| x.to_i } <=> [3, 1]) >= 1
+ assert_errors expression(source), source, [
+ ["Repeated parameter name", 14..15],
+ ], compare_ripper: compare_ripper
+ end
+
private
def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby")