Skip to content

Commit

Permalink
* lexer.rl: treat numparams as locals (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
iliabylich committed Dec 28, 2023
1 parent 41dc835 commit 30ec547
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/parser/lexer.rl
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,8 @@ class Parser::Lexer

if !@static_env.nil? && @static_env.declared?(tok)
fnext expr_endfn; fbreak;
elsif @version >= 33 && tok =~ /\A_[1-9]\z/
fnext expr_endfn; fbreak;
else
fnext *arg_or_cmdarg(cmd_state); fbreak;
end
Expand Down
21 changes: 21 additions & 0 deletions test/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10468,6 +10468,27 @@ def test_reserved_for_numparam__since_30
end
end

def test_numparam_ruby_bug_19025
assert_diagnoses_many(
[
[:warning, :ambiguous_prefix, { :prefix => '**' }],
[:error, :unexpected_token, { :token => 'tDSTAR' }]
],
'p { [_1 **2] }',
%w[3.0 3.1 3.2])

assert_parses(
s(:numblock,
s(:send, nil, :p), 1,
s(:array,
s(:send,
s(:lvar, :_1), :**,
s(:int, 2)))),
'p { [_1 **2] }',
%q{},
SINCE_3_3)
end

def test_endless_setter
assert_diagnoses(
[:error, :endless_setter],
Expand Down

0 comments on commit 30ec547

Please sign in to comment.