-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Constants are not very constant #6221
Comments
heh, I never added a check for that, you must be the first person to find On Sat, Aug 20, 2016 at 6:00 PM, Remixful notifications@github.com wrote:
|
Wow, I thought constants were a compile-time feature? (can they even be?) |
I think they are, expressions using them will be reduced properly at On Aug 20, 2016 18:09, "Marc" notifications@github.com wrote:
|
I mean, if they are processed at compile time, how can they even be modified? Why a check at runtime would even be required? (like writing 1 = 999 is impossible) But I'm not sure if it's technically possible to do that way in GDScript (correct me if I'm wrong) |
I think they are indeed processed at compile time, but reduz didn't write a check for an assignment statement involving constants, changing their value. This is probably what's happening:
|
Reopening as the change was reverted. |
I will kick to 3.1, since at some point want to add optional typing checks. Those checks will be assignment verifications, so will have the chance to add this code there too (which is also an assignment verification) |
Should be solved by #19264. |
Operating system or device - Godot version:
Windows 10 - v2.1.stable.official on Steam
Issue description (what happened, and what was expected):
I'm not sure if this is intentional or not since I can't find any documentation on it. I'm able to modify the value of constants after they are declared, including the @Gloabl Scope constants. Usually in other languages constants aren't variables and may not be modified.
Steps to reproduce:
Try this in any function that will get called:
Output:
You can even try declaring your own constants.
The text was updated successfully, but these errors were encountered: