Skip to content

Commit

Permalink
+ lexer.rl: reject ->... and ->(...) with the same error. (#713)
Browse files Browse the repository at this point in the history
This commit tracks upstream commit ruby/ruby@c0ba35f.
  • Loading branch information
iliabylich committed Jun 15, 2020
1 parent c215622 commit c56ca2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion lib/parser/lexer.rl
Expand Up @@ -2030,7 +2030,14 @@ class Parser::Lexer

'...'
=> {
if @version >= 27
if @version >= 28
if @lambda_stack.any? && @lambda_stack.last + 1 == @paren_nest
# To reject `->(...)` like `->...`
emit(:tDOT3)
else
emit(:tBDOT3)
end
elsif @version >= 27
emit(:tBDOT3)
else
emit(:tDOT3)
Expand Down
8 changes: 7 additions & 1 deletion test/test_parser.rb
Expand Up @@ -7912,7 +7912,13 @@ def test_forward_args_invalid
[:error, :unexpected_token, { :token => 'tBDOT3' }],
%q{->(...) {}},
%q{ ^^^ location},
SINCE_2_7)
['2.7'])

assert_diagnoses(
[:error, :unexpected_token, { :token => 'tDOT3' }],
%q{->(...) {}},
%q{ ^^^ location},
SINCE_2_8)

# Here and below the parser asssumes that
# it can be a beginningless range, so the error comes after reducing right paren
Expand Down

0 comments on commit c56ca2f

Please sign in to comment.