Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* lexer.rl: treat numparams as locals #968

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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