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

[Ruby 3.0 support] Assigning to numbered parameter #2506

Conversation

andrykonchin
Copy link
Member

This PR addresses

[easy] Assigning to a numbered parameter is now a SyntaxError instead of
a warning.

Related issue - #2453

Changes:

  • added specs to cover this case for Ruby 2.7 and Ruby 3.0
  • raise SyntaxError instead of warning

: node.getPosition();
warnNumberedParameterLikeDeclaration(position, name);
// assigning to a numbered parameter is a SyntaxError
throw compile_error(name + " is reserved for numbered parameter");
Copy link
Member Author

@andrykonchin andrykonchin Oct 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I am not sure whether it's a safe change. I just have found a place where the proper warning is printed in the proper situation (and it fixes the added specs).

Also, the else branch with throw compile_error("Can't assign to numbered parameter " + name); looks pretty suspicious and looks like covers quite a similar case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks fine, and the change is indeed AFAIK the warning is replaced by an error.

Copy link
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the specs and change!

: node.getPosition();
warnNumberedParameterLikeDeclaration(position, name);
// assigning to a numbered parameter is a SyntaxError
throw compile_error(name + " is reserved for numbered parameter");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks fine, and the change is indeed AFAIK the warning is replaced by an error.

@eregon eregon self-assigned this Oct 18, 2021
@eregon eregon added the in-ci The PR is being tested in CI. Do not push new commits. label Oct 18, 2021
@eregon eregon added this to the 22.0.0 milestone Oct 21, 2021
@eregon eregon force-pushed the ruby-3-0-support-assigning-to-numbered-parameter branch from c6f6cef to cad8cba Compare October 21, 2021 13:21
@graalvmbot graalvmbot merged commit 7af6b36 into oracle:master Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-ci The PR is being tested in CI. Do not push new commits. oca-signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants