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

Part of the parsing for the ternary operator is not compatible with Ruby 2.2+ #1041

Open
koic opened this issue Oct 7, 2024 · 0 comments
Open

Comments

@koic
Copy link
Collaborator

koic commented Oct 7, 2024

The following changes have been made between Ruby 2.1 and earlier and 2.2 and later:

Ruby 2.1 and ealier:

$ ruby -cve 'x ? !y: z'
ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-darwin13.0]
-e:1: syntax error, unexpected tLABEL
x ? !y: z
       ^

Ruby 2.2 and later:

$ ruby -cve 'x ? !y: z'
ruby 2.2.10p489 (2018-03-28 revision 63023) [x86_64-darwin17]
Syntax OK

Expected Behavior:

In Ruby 2.2 and later, the expression x ? !y : z is successfully parsed without parse error.

Actual Behavior:

The latest version of the Parser gem (3.3.5.0) still follows the behavior of Ruby 2.1 and earlier, which raises a syntax error when attempting to parse x ? !y : z.

For example:

$ ruby-parse --22 -e 'x ? !y: z'
(fragment:0):1:6: error: unexpected token tLABEL
(fragment:0):1: x ? !y: z
(fragment:0):1:      ^~

$ ruby-parse --33 -e 'x ? !y: z'
(fragment:0):1:6: error: unexpected token tLABEL
(fragment:0):1: x ? !y: z
(fragment:0):1:      ^~
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