-
Notifications
You must be signed in to change notification settings - Fork 170
Description
I'm not sure if this is a prism concern or a Ruby concern, but the syntax errors that Ruby prints are relatively challenging to parse for something like flycheck
(flycheck/flycheck#2111). It's easy enough if we only want to highlight the very first syntax error, but if we would like to highlight all of the lines that there are errors along with the message it would require a multi-line regular expression (and counting spaces to ascertain the column). For a human they look great, so my concern is only about machine parsing.
$ echo "do\ndo" | ruby -wc
/redacted-path/ruby: -:1: syntax errors found (SyntaxError)
> 1 | do
| ^~ unexpected 'do', ignoring it
> 2 | do
| ^~ unexpected 'do', ignoring it
I'm curious if there could be a mode where Ruby printed the syntax errors each on their own line, similar to how warnings are printed:
$ echo "1 +x 2 do\ndo" | ruby -wc
-:1: warning: '+' after local variable or literal is interpreted as binary operator even though it seems like unary operator
-:1: warning: possibly useless use of + in void context
-:1: warning: possibly useless use of a literal in void context
/redacted-path/ruby: -:1: syntax errors found (SyntaxError)
> 1 | 1 +x 2 do
| ^ unexpected integer, expecting end-of-input
| ^~ unexpected 'do', ignoring it
| ^~ unexpected 'do', expecting end-of-input
> 2 | do
| ^~ unexpected 'do', ignoring it
It's also unclear why the interpreter path is included in the syntax error output but not for the warnings. It's a seemingly odd inconsistency, but perhaps there is a reason for it.
If I should post this message to https://bugs.ruby-lang.org/ instead, please let me know. Thank you!