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

error: unexpected token kDO #507

Closed
y-yagi opened this issue Apr 25, 2018 · 1 comment
Closed

error: unexpected token kDO #507

y-yagi opened this issue Apr 25, 2018 · 1 comment
Assignees

Comments

@y-yagi
Copy link

y-yagi commented Apr 25, 2018

It is a bug similar to #466 and #447, but it is reproduced with v2.5.1.0.

# test.rb
check_open = -> *args do
  # ...
end

check_open.call
$ ruby-parse -v
ruby-parse based on parser version 2.5.1.0 

$ ruby-parse test.rb
test.rb:1:23: error: unexpected token kDO
test.rb:1: check_open = -> *args do
test.rb:1:                       ^~ 

$ ruby-parse _2.4.0.2_ test.rb
warning: parser/current is loading parser/ruby25, which recognizes
warning: 2.5.0-compliant syntax, but you are running 2.5.1.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
(begin
  (lvasgn :check_open
    (block
      (lambda)
      (args
        (restarg :args)) nil))
  (send
    (lvar :check_open) :call)) 

$ ruby -vc test.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Syntax OK 
@iliabylich
Copy link
Collaborator

$ bin/ruby-parse -E test.rb
check_open = -> *args do
^~~~~~~~~~ tIDENTIFIER "check_open"             expr_cmdarg  [0 <= cond] [0 <= cmdarg]
check_open = -> *args do
           ^ tEQL "="                           expr_beg     [0 <= cond] [0 <= cmdarg]
check_open = -> *args do
             ^~ tLAMBDA "->"                    expr_endfn   [0 <= cond] [0 <= cmdarg]
check_open = -> *args do
                ^ tSTAR2 "*"                    expr_value   [0 <= cond] [0 <= cmdarg]
check_open = -> *args do
                 ^~~~ tIDENTIFIER "args"        expr_cmdarg  [0 <= cond] [0 <= cmdarg]
check_open = -> *args do
                      ^~ kDO "do"               expr_value   [0 <= cond] [0 <= cmdarg]
test.rb:1:23: error: unexpected token kDO
test.rb:1: check_open = -> *args do
test.rb:1:                       ^~

At least it's not related to @cmdarg. There's a wrong state after tIDENTIFIER, MRI transitions to EXPR_ARG (and old versions of parser too), so I guess something is wrong with the @command_state and arg_or_cmdarg method. I'll take a look a bit later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants