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
Godot v4.1.2.stable.mono - Manjaro Linux #1 SMP PREEMPT Sat Sep 23 10:10:02 UTC 2023 - Wayland - Vulkan (Forward+) - integrated Intel(R) UHD Graphics 620 (KBL GT2) () - Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (8 Threads)
Issue description
When calling a GDScript function from C# (using the .Call function), if the type of a given parameter doesn't match the GDScript type annotation, then the GDScript function is never called and no errors or warnings are given. Not having a runtime error/warning makes it difficult to track down bugs caused by mismatched types across the GDScript/C# boundary.
Update: Just tested by calling a GDScript function that doesn't exist (e.g. .Call("non_existent_function")), and the behavior is identical to calling a function with miss-matched parameter types, i.e. no error or warning is given.
Steps to reproduce
Here is an example:
Create a new C# project.
Create a new Node2D scene.
Attach a new C# script to the Node2D with the following contents (let's call it Main.cs):
using Godot;
public partial class Main : Node2D
{
public override void _Ready()
{
GD.Print("Before GDScript call.");
GetNode("/root/Singleton").Call("gdscript_function", <<PLACE VALUE HERE>>);
}
}
Create singleton.gd with the following contents and add it to the list of project autoloads:
If <<PLACE VALUE HERE>> is the string "Bill", the output is as expected:
Before GDScript call.
Hello world says Bill!
If <<PLACE VALUE HERE>> is not a string, 1234, the output is not as expected:
Before GDScript call.
Expected output:
Before GDScript call.
Error: Function `gdscript_function` was given a value of type `int`, but `String` was expected.
Everything works as expected if I modify singleton.gd to remove the type annotation (and cast player_name to a string to avoid Invalid operands 'String' and 'int' in operator '+'.):
Godot version
v4.1.2.stable.mono.official [399c9dc]
System information
Godot v4.1.2.stable.mono - Manjaro Linux #1 SMP PREEMPT Sat Sep 23 10:10:02 UTC 2023 - Wayland - Vulkan (Forward+) - integrated Intel(R) UHD Graphics 620 (KBL GT2) () - Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (8 Threads)
Issue description
When calling a GDScript function from C# (using the
.Call
function), if the type of a given parameter doesn't match the GDScript type annotation, then the GDScript function is never called and no errors or warnings are given. Not having a runtime error/warning makes it difficult to track down bugs caused by mismatched types across the GDScript/C# boundary.Update: Just tested by calling a GDScript function that doesn't exist (e.g.
.Call("non_existent_function")
), and the behavior is identical to calling a function with miss-matched parameter types, i.e. no error or warning is given.Steps to reproduce
Here is an example:
Create a new C# project.
Create a new Node2D scene.
Attach a new C# script to the Node2D with the following contents (let's call it
Main.cs
):Create
singleton.gd
with the following contents and add it to the list of project autoloads:If
<<PLACE VALUE HERE>>
is the string"Bill"
, the output is as expected:If
<<PLACE VALUE HERE>>
is not a string,1234
, the output is not as expected:Expected output:
Everything works as expected if I modify
singleton.gd
to remove the type annotation (and castplayer_name
to a string to avoidInvalid operands 'String' and 'int' in operator '+'.
):Minimal reproduction project
godot_project.zip
The text was updated successfully, but these errors were encountered: