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

Incompatibility in syntax errors regarding "void value expression" #995

Open
koic opened this issue Feb 26, 2024 · 0 comments
Open

Incompatibility in syntax errors regarding "void value expression" #995

koic opened this issue Feb 26, 2024 · 0 comments

Comments

@koic
Copy link
Collaborator

koic commented Feb 26, 2024

There is an incompatibility in syntax errors for "void value expression" between Parser gem and Ruby.

Expected

a 1,break,1 has been a syntax error since at least Ruby 2.0:

$ ruby -vce 'a 1,break,1'
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin13.0.2]
-e:1: void value expression
a 1,break,1
          ^

The same goes for Ruby 3.3:

$ ruby -vce 'a 1,break,1'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
-e:1: void value expression
a 1,break,1
-e:1: Invalid break
a 1,break,1
-e: compile error (SyntaxError)

Actual

Although the Parser gem is able to parse it, this is likely an unexpected behavior:

$ ruby-parse --33 -e 'a 1,break,1'
(send nil :a
  (int 1)
  (break)
  (int 1))

The same goes for return, next, and redo.

koic added a commit to rubocop/rubocop that referenced this issue Feb 26, 2024
`a 1,next,1` has been a syntax error since at least Ruby 2.0:

```console
$ ruby -vce 'a 1,next,1'
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin13.0.2]
-e:1: void value expression
a 1,next,1
         ^
```

The same goes for Ruby 3.3:

```console
$ ruby -vce 'a 1,next,1'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
-e:1: void value expression
a 1,next,1
-e:1: Invalid next
a 1,next,1
-e: compile error (SyntaxError)
```

Although the Parser gem is able to parse it, this is likely an unexpected behavior:

```console
$ ruby-parse --33 -e 'a 1,next,1'
(send nil :a
  (int 1)
  (next)
  (int 1))
```

The issue regarding this is below:
whitequark/parser#995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant