-
-
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
GDScript line incorrectly marked as unsafe #88152
Comments
Those two pieces of code aren't equivalent though, the types are different, the safety analysis might be missing some cases though but the change to the code means different types This: const EXIT_DIR := [ Which is equivalent to: const EXIT_DIR : Array = [ Is not equivalent to: const EXIT_DIR : Array[Vector2i] = [ |
I have noticed this issue often. Still somewhat of a nuisance, especially since these arrays cannot really be modified. |
We should be able to do static checking on the elements of the array, but the clarification is that the issue isn't the type of the array but that the safety check doesn't seem to go deeper than the array type return, this might not be entirely simple either I don't know the specifics here |
As per #46830, I thought the full array type was infered... |
The type is inferred, the type being an untyped array, otherwise you'd have bugs and unforseen behavior, like: var arr := [1, 2, 3]
arr.push_back("Test") That should still work and not throw an error The issue is that the unsafe check doesn't look into the array, the type shouldn't be inferred to |
Note that even an array declared like |
That's not the case for recent Godot versions. If you call e.g. append you will get an error like |
Tested versions
v4.3.dev3.official [36e943b]
System information
Godot v4.3.dev3 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.5123) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)
Issue description
The line 13 below is marked as unsafe while the line 12 is marked as safe:
Both lines are marked as safe if I replace the line 3 by:
It should work the same with both syntax.
Steps to reproduce
Create a new GDScript and paste this code:
Minimal reproduction project (MRP)
See above.
The text was updated successfully, but these errors were encountered: