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

Parsing for -> { yield } is not compatible with Ruby 3.3+ #1042

Open
koic opened this issue Oct 14, 2024 · 1 comment
Open

Parsing for -> { yield } is not compatible with Ruby 3.3+ #1042

koic opened this issue Oct 14, 2024 · 1 comment

Comments

@koic
Copy link
Collaborator

koic commented Oct 14, 2024

The following changes have been made between Ruby 3.2 and earlier and 3.3 and later:

Ruby 3.2 and earlier:

$ ruby -vce '-> { yield }'
ruby 3.2.4 (2024-04-23 revision af471c0e01) [x86_64-darwin23]
Syntax OK

Ruby 3.3 and later:

$ ruby -vce '-> { yield }'
ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-darwin23]
-e:1: Invalid yield
-> { yield }
ruby: compile error (SyntaxError)

Expected Behavior:

In Ruby 3.3 and later, the expression -> { yield } raises a syntax error.

Actual Behavior:

The latest version of the Parser gem (3.3.5.0) still follows the behavior of Ruby 3.2 and earlier, which successfully parsed without parse error when attempting to parse -> { yield }.

For example:

$ ruby-parse --32 -e '-> { yield }'
(block
  (lambda)
  (args)
  (yield))

$ ruby-parse --33 -e '-> { yield }'
(block
  (lambda)
  (args)
  (yield))
@iliabylich
Copy link
Collaborator

Correct, it's a documented incompatibility. parser doesn't do checks that MRI does outside of parse.y (in compile.c in this case I believe)

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

2 participants