* [ruby-core:120035] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist
@ 2024-11-28 4:38 mame (Yusuke Endoh) via ruby-core
2024-11-30 23:04 ` [ruby-core:120072] " ydah (Yudai Takada) via ruby-core
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2024-11-28 4:38 UTC (permalink / raw)
To: ruby-core; +Cc: mame (Yusuke Endoh)
Issue #20918 has been reported by mame (Yusuke Endoh).
----------------------------------------
Bug #20918: Prism error indicates line number of `-e` that does not exist
https://bugs.ruby-lang.org/issues/20918
* Author: mame (Yusuke Endoh)
* Status: Open
* 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 -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:120072] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist
2024-11-28 4:38 [ruby-core:120035] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist mame (Yusuke Endoh) via ruby-core
@ 2024-11-30 23:04 ` ydah (Yudai Takada) via ruby-core
2024-12-04 14:58 ` [ruby-core:120101] " kddnewton (Kevin Newton) via ruby-core
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ydah (Yudai Takada) via ruby-core @ 2024-11-30 23:04 UTC (permalink / raw)
To: ruby-core; +Cc: ydah (Yudai Takada)
Issue #20918 has been updated by ydah (Yudai Takada).
It seems that the `foo {` has the same problem.
````
❯ ruby -e 'foo {'
-e: -e:2: syntax errors found (SyntaxError)
> 1 | foo {
| ^ expected a block beginning with `{` to end with `}`
> 2 |
| ^ unexpected end-of-input, assuming it is closing the parent top level context
```
Since the error is not confirmed until EOL, it looks like you are outputting the position where the error is confirmed.
```
❯ ruby -e "foo(
"
-e: -e:4: syntax error found (SyntaxError)
2 |
3 |
> 4 |
| ^ unexpected end-of-input; expected a `)` to close the arguments
```
----------------------------------------
Bug #20918: Prism error indicates line number of `-e` that does not exist
https://bugs.ruby-lang.org/issues/20918#change-110815
* Author: mame (Yusuke Endoh)
* Status: Open
* 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 -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:120101] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist
2024-11-28 4:38 [ruby-core:120035] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist mame (Yusuke Endoh) via ruby-core
2024-11-30 23:04 ` [ruby-core:120072] " ydah (Yudai Takada) via ruby-core
@ 2024-12-04 14:58 ` kddnewton (Kevin Newton) via ruby-core
2024-12-04 16:15 ` [ruby-core:120103] " tenderlovemaking (Aaron Patterson) via ruby-core
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kddnewton (Kevin Newton) via ruby-core @ 2024-12-04 14:58 UTC (permalink / raw)
To: ruby-core; +Cc: kddnewton (Kevin Newton)
Issue #20918 has been updated by kddnewton (Kevin Newton).
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?
----------------------------------------
Bug #20918: Prism error indicates line number of `-e` that does not exist
https://bugs.ruby-lang.org/issues/20918#change-110849
* 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 -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:120103] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist
2024-11-28 4:38 [ruby-core:120035] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist mame (Yusuke Endoh) via ruby-core
2024-11-30 23:04 ` [ruby-core:120072] " ydah (Yudai Takada) via ruby-core
2024-12-04 14:58 ` [ruby-core:120101] " kddnewton (Kevin Newton) via ruby-core
@ 2024-12-04 16:15 ` tenderlovemaking (Aaron Patterson) via ruby-core
2024-12-12 10:56 ` [ruby-core:120210] " mame (Yusuke Endoh) via ruby-core
2024-12-12 18:44 ` [ruby-core:120222] " tenderlovemaking (Aaron Patterson) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: tenderlovemaking (Aaron Patterson) via ruby-core @ 2024-12-04 16:15 UTC (permalink / raw)
To: ruby-core; +Cc: tenderlovemaking (Aaron Patterson)
Issue #20918 has been updated by tenderlovemaking (Aaron Patterson).
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?
I'm not sure if it matters. If you have a script with one line (that has a newline), Prism will report line 2 as the error.
```
[aaron@tc-lan-adapter ~/g/ruby (master)]$ cat x.rb
foo(
[aaron@tc-lan-adapter ~/g/ruby (master)]$ od -c x.rb
0000000 f o o ( \n
0000005
[aaron@tc-lan-adapter ~/g/ruby (master)]$ wc -l x.rb
1 x.rb
[aaron@tc-lan-adapter ~/g/ruby (master)]$ ./miniruby x.rb
x.rb: x.rb:2: syntax error found (SyntaxError)
1 | foo(
> 2 |
| ^ unexpected end-of-input; expected a `)` to close the arguments
[aaron@tc-lan-adapter ~/g/ruby (master)]$
```
It's fine for newlines to appear in method parameters as well as blocks, so Prism considers the EOF token to be the "error token". Indeed EOF "occurs" on line 2 (since it's after the newline), but since nobody writes EOF in to their files, I think we should consider the error to have occurred at the newline preceding EOF.
One more example:
```
[aaron@tc-lan-adapter ~/g/ruby (master)]$ cat x.rb
foo(
[aaron@tc-lan-adapter ~/g/ruby (master)]$ wc -l x.rb
5 x.rb
[aaron@tc-lan-adapter ~/g/ruby (master)]$ od -c x.rb
0000000 f o o ( \n \n \n \n \n
0000011
[aaron@tc-lan-adapter ~/g/ruby (master)]$ ./miniruby x.rb
x.rb: x.rb:6: syntax error found (SyntaxError)
4 |
5 |
> 6 |
| ^ unexpected end-of-input; expected a `)` to close the arguments
[aaron@tc-lan-adapter ~/g/ruby (master)]$
```
Most tools agree the above file only has 5 lines in it, but Prism reports the error on line 6. IMO errors should only occur on lines that exist.
----------------------------------------
Bug #20918: Prism error indicates line number of `-e` that does not exist
https://bugs.ruby-lang.org/issues/20918#change-110851
* 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 -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:120210] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist
2024-11-28 4:38 [ruby-core:120035] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist mame (Yusuke Endoh) via ruby-core
` (2 preceding siblings ...)
2024-12-04 16:15 ` [ruby-core:120103] " tenderlovemaking (Aaron Patterson) via ruby-core
@ 2024-12-12 10:56 ` mame (Yusuke Endoh) via ruby-core
2024-12-12 18:44 ` [ruby-core:120222] " tenderlovemaking (Aaron Patterson) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2024-12-12 10:56 UTC (permalink / raw)
To: ruby-core; +Cc: mame (Yusuke Endoh)
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 -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [ruby-core:120222] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist
2024-11-28 4:38 [ruby-core:120035] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist mame (Yusuke Endoh) via ruby-core
` (3 preceding siblings ...)
2024-12-12 10:56 ` [ruby-core:120210] " mame (Yusuke Endoh) via ruby-core
@ 2024-12-12 18:44 ` tenderlovemaking (Aaron Patterson) via ruby-core
4 siblings, 0 replies; 6+ messages in thread
From: tenderlovemaking (Aaron Patterson) via ruby-core @ 2024-12-12 18:44 UTC (permalink / raw)
To: ruby-core; +Cc: tenderlovemaking (Aaron Patterson)
Issue #20918 has been updated by tenderlovemaking (Aaron Patterson).
mame (Yusuke Endoh) wrote in #note-6:
> @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.
Strange. Thank you, I'll try to figure it out!
----------------------------------------
Bug #20918: Prism error indicates line number of `-e` that does not exist
https://bugs.ruby-lang.org/issues/20918#change-110986
* 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 -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-12-12 18:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-28 4:38 [ruby-core:120035] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist mame (Yusuke Endoh) via ruby-core
2024-11-30 23:04 ` [ruby-core:120072] " ydah (Yudai Takada) via ruby-core
2024-12-04 14:58 ` [ruby-core:120101] " kddnewton (Kevin Newton) via ruby-core
2024-12-04 16:15 ` [ruby-core:120103] " tenderlovemaking (Aaron Patterson) via ruby-core
2024-12-12 10:56 ` [ruby-core:120210] " mame (Yusuke Endoh) via ruby-core
2024-12-12 18:44 ` [ruby-core:120222] " tenderlovemaking (Aaron Patterson) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).