[ruby-core:120210] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist
From:
"mame (Yusuke Endoh) via ruby-core" <ruby-core@...>
Date:
2024-12-12 10:56:00 UTC
List:
ruby-core #120210
Issue #20918 has been updated by mame (Yusuke Endoh).
Status changed from Closed to Assigned
@tenderlovemaking Thank you for fixing the issue, but it still shows line 2 in the code snippet.
```
$ ruby -e "foo("
-e: -e:1: syntax error found (SyntaxError)
> 1 | foo(
| ^ unexpected end-of-input; expected a `)` to close the arguments
2 |
```
I don't think ` 2 |` should be printed.
kddnewton (Kevin Newton) wrote in #note-3:
> I looked into this this morning, it looks like ruby.c is automatically concatenating a \n onto the -e script here: https://github.com/ruby/ruby/blob/f43585b02c3634ab9a4e54049b08e04ab1a640fd/ruby.c#L1303. Is this desired behavior?
According to @nobu, the new line is intentionally added to separate expressions for multiple `-e` options.
```
$ ruby -e 'p 1' -e 'p 2'
1
2
$ ruby -e 'p 1 +' -e '2'
3
```
However, I don't think it should be printed in an error message and snippet.
----------------------------------------
Bug #20918: Prism error indicates line number of `-e` that does not exist
https://bugs.ruby-lang.org/issues/20918#change-110973
* Author: mame (Yusuke Endoh)
* Status: Assigned
* Assignee: prism
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------
```
$ ruby -e 'foo('
-e: -e:2: syntax error found (SyntaxError)
1 | foo(
> 2 |
| ^ unexpected end-of-input; expected a `)` to close the arguments
```
It says `-e:2`, but there is no line 2 in `-e 'foo('`.
`eval("foo(")` reports line 1, so I guess this issue is only for `-e`.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- [email protected]
To unsubscribe send an email to [email protected]
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/