parser icon indicating copy to clipboard operation
parser copied to clipboard

ruby/ruby@e369884

Open iliabylich opened this issue 1 year ago • 1 comments

https://github.com/ruby/ruby/commit/e36988450e9e9ccccb41c72135f1e57790920668

iliabylich avatar Apr 14 '24 17:04 iliabylich

Disallow anonymous block within argument forwarding

For parser, this is already the case since argument forwarding was introduced:

$ ruby -cve 'def f(...); g(&); end'
ruby 3.1.6p260 (2024-05-29 revision a777087be6) [x86_64-linux]
Syntax OK

$ ruby-parse --31 -e "def f(...); g(&); end"
(fragment:0):1:15: error: no anonymous block parameter
(fragment:0):1: def f(...); g(&); end
(fragment:0):1:               ^

I guess, should be allowed for those earlier versions but I'm not going to look into it further than this for now.

def test_anonymous_blockarg_with_arg_forwarding
  assert_diagnoses(
    [:error, :no_anonymous_blockarg],
    %q{def foo(...); bar(&); end},
    %q{                  ^ location},
    SINCE_3_1)
end

Earlopain avatar Dec 17 '24 16:12 Earlopain