-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
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
GDScript enums override constants. #13175
Comments
I haven't tested but it's likely the same in master too, so should be fixed for both. cc @bojidar-bg |
AFAIK, this is expected. It's similar to C++ enums. It should error because NUMBER is already declared though. |
Yeah, I tagged "bug" because it's a bug that it allows this shadowing instead of erroring out. |
Related to #6221. |
Per #6221 (comment) @reduz intends (intended?) to leave this issue for 3.1. |
I think we should add some way to mark enums as "to-be-kept-as-dictionary-only". Some examples to explain it: enum {INT = 1, STRING}
# equivalent to:
const INT = 1; const STRING = 2
# ---
enum Type {INT = 1, STRING}
# equivalent to:
const INT = 1; const STRING = 2
const Type = {INT = 1, STRING = 2}
# ---
!enum Type {INT = 1, STRING} # some cool proposal here
# equivalent to:
const Type = {INT = 1, STRING = 2} Now, the question is how to mark those enums, feel free to propose the syntax 😃 . |
No, we don't need to add support for half shadowing. Just trigger a syntax error when an enum shadows a constant. |
@bojidar-bg I don't get the point, if you need just a dictionary you can simply make one. There's no much gain in avoiding to set the values manually. |
@bojidar-bg guess popular demand here just wants an error to be triggered :) |
We have now entered release freeze for Godot 3.0 and want to focus only on release critical issues for that milestone. Therefore, we're moving this issue to the 3.1 milestone, though a fix may be made available for a 3.0.x maintenance release after it has been tested in the master branch during 3.1 development. If you consider that this issue is critical enough to warrant blocking the 3.0 release until fixed, please comment so that we can assess it more in-depth. |
@vnen , @bojidar-bg what to do with this? |
I'm using Windows version of 2.1.
The problem I ran into is that enums using the same names as constants will replace their value.
Such as:
The text was updated successfully, but these errors were encountered: