Variables with wrong types become 0 instead of being cast correctly #907
Labels
bug
This has been identified as a bug
confirmed
topic:gdextension
This relates to the new Godot 4 extension implementation
Milestone
Say I have the following function in a GDExtension project:
As expected, calling
example.print_variables(123.0, 321)
from GDScript prints "123 and 321" to the console.However, when the types do not match (e.g. mixing up float and int), they are not properly cast automatically: the debugger does print a warning like
Narrowing conversion (float is converted to int and loses precision)
, but the output is not still "123 and 321" as I would expect. Rather, the variable with the false type is simply 0.Example: calling
example.print_variables(123, 321)
(first argument is now int rather than float) produces "0 and 321" in the console.This type of bug is really hard to track down in a reasonably complex project, so I would expect either a full error if the types don't match, or a better automatic conversion.
Here's a minimal reproduction (just a quick modification of the example project from this repo): type-cast-repro.zip running it in Godot shows that, as described above, parameters with wrong types simply become 0. This is the case even if Godot's optional static typing is not used (
=
rather than:=
).Tested in Godot 4.0 Beta 3
The text was updated successfully, but these errors were encountered: