-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Const expressions of equal value and type are shared #56306
Comments
I can confirm this on This does not occur on 3.5.beta (a75afd6), so this is a regression in the new GDScript implementation in
PS: For correct syntax highlighting, code blocks should use |
I think the solution here is to ensure the bits are equal instead of checking that |
Godot version
4.0.dev (28174d5)
System information
5.15.2-2-MANJARO
Issue description
I couldn't find any open issue about this behavior of
const
.const
initializer expressions that reduce to the same type and same (==
) value are shared, as an optimization I assume. But this can lead to unexpected situations.According to the docs,
const
arrays are intended to be mutable. This is fine by itself, but with the sharing behavior, it is chaos:Output:
Note: This is not only for empty arrays.
I believe another issue, brought up by @aaronfranke on rocket chat, is caused by the same behavior:
and:
Steps to reproduce
Just run the code blocks in "Issue description".
Minimal reproduction project
No response
The text was updated successfully, but these errors were encountered: