Open
Description
Tested versions
- Reproducible in 4.4.1.stable
System information
Godot v4.4.1.stable - macOS Sequoia (15.5.0) - Single-window, 2 monitors - Metal (Forward+) - integrated Apple M2 Max (Apple8) - Apple M2 Max (12 threads)
Issue description
In the documentation, the as
operator/keyword can be used to cast between built-in types. And in the same documentation, it gives the following snippet as an example:
var my_int: int
my_int = "123" as int # The string can be converted to int.
my_int = Vector2() as int # A Vector2 can't be converted to int, this will cause an error.
And the int
built-in type does have a constructor that can construct from String
, so "123" as int
should work.
But in Godot 4.4.1.stable, any "123" as int
raises Parse Error: Cannot cast a value of type "String" as "int"
, whereas int("123")
works fine.

Not yet noticed another case that a corresponding constructor exists but as
keyword casting fails other than String as int
.
Steps to reproduce
Try "123" as int
Minimal reproduction project (MRP)
N/A
Metadata
Metadata
Assignees
Type
Projects
Status
For team assessment