diff options
| author | TSUYUSATO Kitsune <make.just.on@gmail.com> | 2023-11-24 01:29:18 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-11-28 17:27:09 +0000 |
| commit | b5796d7b113a78b17e27f2ad23c209f4e2d2900b (patch) | |
| tree | 72305bb09db658e189711bc6878dc8e880d69159 /test | |
| parent | fadd28c7ba6b55ec934f379cfc30a8111e340404 (diff) | |
[ruby/prism] Check circular references in default values of params
Fix https://github.com/ruby/prism/pull/1637
https://github.com/ruby/prism/commit/0172d69cba
Diffstat (limited to 'test')
| -rw-r--r-- | test/prism/errors_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb index bcc9629622..9c96725463 100644 --- a/test/prism/errors_test.rb +++ b/test/prism/errors_test.rb @@ -1829,6 +1829,22 @@ module Prism ] end + def test_circular_param + source = <<~RUBY + def foo(bar = bar) = 42 + def foo(bar: bar) = 42 + proc { |foo = foo| } + proc { |foo: foo| } + RUBY + message = 'Invalid circular reference in a default parameter' + assert_errors expression(source), source, [ + [message, 14..17], + [message, 37..40], + [message, 61..64], + [message, 81..84], + ], compare_ripper: false # Ripper does not check 'circular reference'. + end + private def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby") |
