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

Parser does not reject invalid operator names for implicit object calls #10824

Open
HertzDevil opened this issue Jun 14, 2021 · 0 comments · May be fixed by #15526
Open

Parser does not reject invalid operator names for implicit object calls #10824

HertzDevil opened this issue Jun 14, 2021 · 0 comments · May be fixed by #15526
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser

Comments

@HertzDevil
Copy link
Contributor

The parser will accept code like below:

case 1
when .&&(2) # Error: undefined method '&&' for Int32
when .=(3)  # ditto
when .+=(4) # ditto
end

They all produce errors in the semantic phase only because it is indeed impossible to define those methods (&& is syntactic sugar for if, = is plain assignment, and += is an OpAsssign that will be normalized shortly). It should be possible to move the error to the syntactic phase without breaking any existing code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants