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

Error when declaring a constant within another constant declaration #12566

Conversation

caspiano
Copy link
Contributor

@caspiano caspiano commented Oct 5, 2022

The following code will now raise a syntax error, as constants must be declared at the top level or within a type.

A = B = 1

Resolves #2874

@Blacksmoke16 Blacksmoke16 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:parser labels Oct 5, 2022
@HertzDevil
Copy link
Contributor

Does this handle the snippet with the begin?

@caspiano
Copy link
Contributor Author

caspiano commented Oct 5, 2022

@HertzDevil yep, this is caught by the dynamic constant declaration checking. I'll add a test case for it.

Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
@caspiano caspiano marked this pull request as draft October 5, 2022 09:09
@straight-shoota
Copy link
Member

What happens if the constant assignment is nested in a call?

A = puts(B = 1)

@caspiano caspiano marked this pull request as ready for review October 10, 2022 12:13
Copy link
Member

@sdogruyol sdogruyol 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 @caspiano 🙏

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 this pull request may close these issues.

Compiler crash when defining a constant inside a constant
6 participants