summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-09-13 11:39:09 -0400
committergit <svn-admin@ruby-lang.org>2023-09-15 15:14:37 +0000
commitb5084877c0cd0d3ae74760642cabda1b214d87d2 (patch)
tree70db81bf3974ddcc46edf5bac728334c6935aea2 /test
parenta4b4ebc7c1cfce912e5b8d2d30bcd9f24897bdc5 (diff)
[ruby/yarp] Disallow numbered parameters in multiple scopes
https://github.com/ruby/yarp/commit/5fd4d3b89a
Diffstat (limited to 'test')
-rw-r--r--test/yarp/errors_test.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/yarp/errors_test.rb b/test/yarp/errors_test.rb
index 7003dceb38..89fafdf28d 100644
--- a/test/yarp/errors_test.rb
+++ b/test/yarp/errors_test.rb
@@ -1206,11 +1206,18 @@ module YARP
]
end
+ def test_double_scope_numbered_parameters
+ source = "-> { _1 + -> { _2 } }"
+ errors = [["Numbered parameter is already used in outer scope", 15..17]]
+
+ assert_errors expression(source), source, errors, compare_ripper: false
+ end
+
private
- def assert_errors(expected, source, errors)
+ def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby")
# Ripper behaves differently on JRuby/TruffleRuby, so only check this on CRuby
- assert_nil Ripper.sexp_raw(source) if RUBY_ENGINE == "ruby"
+ assert_nil Ripper.sexp_raw(source) if compare_ripper
result = YARP.parse(source)
node = result.value.statements.body.last