You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Type annotations that are obviously incorrect are accepted on for loop variables, leading to runtime errors (specifically, "Trying to assign a value of type 'int' to a variable of type 'String'"). The implementation PR, #80247, notes that cases where the runtime type is different will cause runtime errors. However, this issue occurs even when the types should be statically known.
Steps to reproduce
Create a project, populate it with a Node3D, and save the scene.
I'm not sure if this is a bug. By default, array literals are untyped (Array aka Array[Variant]), we make literals typed only in some contexts. The following code correctly generates an error:
vara: Array[int] = [1, 2, 3]
# Compile time error: Unable to iterate on value of type# "Array[int]" with variable of type "String".forx: Stringina:
print(x)
varx: Array[String] = [1, 2, 3]
This is one of the cases where we are implicitly converting a literal to a typed array. Maybe we should make the literal typed in this case too, but I'm not sure if that's a good idea.
Godot version
v4.2.dev5.official [e3e2528], v4.2.dev.custom_build [7b49cbade]
System information
Godot v4.2.dev5 - Debian GNU/Linux 12 (bookworm) 12 - X11 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 1060 3GB (nvidia) - AMD Ryzen 7 1700X Eight-Core Processor (16 Threads)
Issue description
Type annotations that are obviously incorrect are accepted on
for
loop variables, leading to runtime errors (specifically, "Trying to assign a value of type 'int' to a variable of type 'String'"). The implementation PR, #80247, notes that cases where the runtime type is different will cause runtime errors. However, this issue occurs even when the types should be statically known.Steps to reproduce
Extra info
Compare the script above to the following script:
This correctly produces an error at compile time:
Minimal reproduction project
godot issue.zip
The text was updated successfully, but these errors were encountered: