Invalid type in static function '…' in type '…'. Cannot convert argument in Godot 4
By Eduardo Orellana · Updated
A static function was called with an argument whose type cannot be converted to the parameter's type. Vector2.from_angle(data.angle), where data.angle is the String "1.5" from JSON, stops with Invalid type in static function 'from_angle' in type 'Vector2'. Cannot convert argument 1 from String to float; convert the value first, Vector2.from_angle(float(data.angle)).
What Godot is checking
When a static function of a built-in type such as Vector2 is called, the arguments are checked against the types the function declares. If one cannot be converted, the call fails, and the VM names the function, the type it belongs to, the argument's position counted from 1, the type it got and the type the parameter expects.
The same message is built for static functions of engine classes, with the class name after in type, from the second static call path in the VM.
It is a runtime error: the script parsed, and the error appeared when the line ran. The function that made the call stops there, so the print("after") below it never ran, as the output shows.
JSON.parse_string() returns a Variant, so the analyzer does not know that data.angle holds a String, and the call is checked only when it runs.
Reproduce it
An angle read from JSON, stored as a string, passed straight to Vector2.from_angle(), which takes a float.
extends Node
func _ready() -> void:
var data = JSON.parse_string('{"angle": "1.5"}')
var direction := Vector2.from_angle(data.angle)
print("after")
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Invalid type in static function 'from_angle' in type 'Vector2'. Cannot convert argument 1 from String to float.
at: _ready (res://answers/invalid-type-in-static-function-cannot-convert-argument/repro.gd:5)
GDScript backtrace (most recent call first):
[0] _ready (res://answers/invalid-type-in-static-function-cannot-convert-argument/repro.gd:5)Fix it
Convert the value to the parameter's type before the call. float() converts a String the same way String.to_float() does.
extends Node
func _ready() -> void:
var data = JSON.parse_string('{"angle": "1.5"}')
var direction := Vector2.from_angle(float(data.angle))
print("direction ", direction)
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
direction (0.070737, 0.997495)Verified on Godot 4.7.2
Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 6 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: [gdscript_vm.cpp line 179, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_vm.cpp#L179), [gdscript_vm.cpp line 2143, static functions of built-in types](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_vm.cpp#L2143), [gdscript_vm.cpp line 2189, static functions of engine classes](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_vm.cpp#L2189), [Vector2.from_angle in the class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Vector2.xml#L211), [JSON.parse_string in the class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/JSON.xml#L83), [float(String) in the class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/float.xml#L30).
Questions
- Why didn't the editor flag the call?
- JSON.parse_string() returns a Variant, so the type of data.angle is not known until the line runs. The repro parsed and failed only when the line ran.
- Did older Godot versions print a different message?
- Godot 4.2 builds the same text: Invalid type in static function '…' in type '…'. Cannot convert argument N from A to B.
Related
- Invalid call to function in base. Expected N argument(s)
- Invalid call. Nonexistent function 'instance' in base 'PackedScene'
- Every verified Godot 4 answer
- Invalid assignment of property or key with value of type on a base object of type 'Nil' in Godot 4
- Trying to assign a non-object value to a variable of type '…' in Godot 4
- Trying to call an async function without "await" in Godot 4
- Invalid access to property or key on a base object of type 'null instance' in Godot 4
- Invalid access to property or key on a base object of type 'Nil' in Godot 4
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free