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

Can't use AModule::AConst = 1 to declare a constant #5742

Closed
bew opened this issue Feb 23, 2018 · 1 comment
Closed

Can't use AModule::AConst = 1 to declare a constant #5742

bew opened this issue Feb 23, 2018 · 1 comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler

Comments

@bew
Copy link
Contributor

bew commented Feb 23, 2018

ModuleFoo::Bar = 1

{% puts ModuleFoo.class_name %} # => NumberLiteral

puts ModuleFoo::Bar  # undefined constant ModuleFoo::Bar

https://carc.in/#/r/3mjb

I would expect it to create a module named ModuleFoo with a constant Bar inside it.
Instead, ModuleFoo::Bar = 1 creates a constant ModuleFoo with value 1, discarding Bar completely.

Apart from the fact that the current behavior is a bug, as we already have a few other places where we can use a module name in front of something, I think it would be consistent to allow this for constants too.

@RX14
Copy link
Member

RX14 commented Feb 23, 2018

Yeah the current behaviour is a bug but I'd also be fine with this being a compile error.

@jhass jhass added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler labels Mar 29, 2018
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
Projects
None yet
Development

No branches or pull requests

3 participants