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

Value omitted hash keys ending with ! or ? are being parsed #2718

Closed
koic opened this issue Apr 19, 2024 · 0 comments · Fixed by #2722
Closed

Value omitted hash keys ending with ! or ? are being parsed #2718

koic opened this issue Apr 19, 2024 · 0 comments · Fixed by #2722

Comments

@koic
Copy link
Contributor

koic commented Apr 19, 2024

Excepted

SyntaxError occurs when a value omitted hash key ends with ! or ?:

$ ruby -vce '{foo!:}'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
-e:1: identifier foo! is not valid to get
-e: compile error (SyntaxError)

$ ruby -vce '{foo?:}'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
-e:1: identifier foo? is not valid to get
-e: compile error (SyntaxError)

Actual

It is parsed as valid syntax when using Prism:

$ ruby --parser=prism -vce '{foo!:}'
ruby: warning: The compiler based on the Prism parser is currently experimental and compatibility with the compiler based on parse.y is not yet complete. Please report any issues you find on the `ruby/prism` issue tracker.
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +PRISM [x86_64-darwin22]
Syntax OK

$ ruby --parser=prism -vce '{foo?:}'
ruby: warning: The compiler based on the Prism parser is currently experimental and compatibility with the compiler based on parse.y is not yet complete. Please report any issues you find on the `ruby/prism` issue tracker.
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) +PRISM [x86_64-darwin22]
Syntax OK

Refer: ruby/spec#1148

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

Successfully merging a pull request may close this issue.

1 participant