mirror of
https://github.com/ruby/ruby.git
synced 2025-08-26 22:45:03 +02:00
[ruby/prism] Fix to check multiple block arguments for forwarding arg
Fix https://github.com/ruby/prism/pull/2111
21ca243d0a
This commit is contained in:
parent
165deec5fe
commit
0ee625ceae
4 changed files with 31 additions and 5 deletions
|
@ -2046,6 +2046,20 @@ module Prism
|
|||
]
|
||||
end
|
||||
|
||||
def test_block_arg_and_block
|
||||
source = 'foo(&1) { }'
|
||||
assert_errors expression(source), source, [
|
||||
['multiple block arguments; only one block is allowed', 8..11]
|
||||
], compare_ripper: false # Ripper does not check 'both block arg and actual block given'.
|
||||
end
|
||||
|
||||
def test_forwarding_arg_and_block
|
||||
source = 'def foo(...) = foo(...) { }'
|
||||
assert_errors expression(source), source, [
|
||||
['both a block argument and a forwarding argument; only one block is allowed', 24..27]
|
||||
], compare_ripper: false # Ripper does not check 'both block arg and actual block given'.
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue