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

Add the column caret line when encountering a SyntaxError #5810

Closed
enebo opened this issue Aug 1, 2019 · 1 comment

Comments

@enebo
Copy link
Member

commented Aug 1, 2019

When we see an error:

SyntaxError: ../snippets/rinda1.rb:12: syntax error, unexpected ';'
DRb.;thread.join if __FILE__ == $0

we see the line the error occured on but we should see:

../snippets/rinda1.rb:12: syntax error, unexpected ';', expecting '('
DRb.;thread.join if __FILE__ == $0
    ^

Note: Ruby 2.6 seems to change this caret into underlining the column in question. The basic plumbing for this is to supply the column the error occurs on so that change for 9.3 should be easy to change to.

@enebo enebo added this to the JRuby 9.2.8.0 milestone Aug 1, 2019

@enebo enebo closed this in 2f5797e Aug 7, 2019

@enebo

This comment has been minimized.

Copy link
Member Author

commented Aug 7, 2019

This actually is a tiny bit different. If the right keyword is noticed to be unexpected MRI somehow knows the range:

system ~/work/jruby master 1043% mri25 -e 'fo; do'
-e:1: syntax error, unexpected keyword_do_block, expecting end-of-input
fo; do
    ^~
system ~/work/jruby master 1044% jruby -e 'fo; do'
SyntaxError: -e:1: syntax error, unexpected keyword_do_block
fo; do
     ^

Making this match exactly can be done later since 2.6 will underline the keyword (vs using a caret) but this is more than adequate to solving the basic issue of pointing out where the syntax error is occuring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.