-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDScript function parameters statically typed as script-defined classes can't be given a default value #26556
Comments
Would be nice to allow for this in situations where you follow with @vnen Currently, is there a proper way of typing an argument to a specific class, and making it optional at the same time? |
I don't know why I specified Reference specifically, this happens with all custom classes. GDScript allows you to assign null to variables statically typed as custom classes, so it should do the same for function parameters. |
I tested a bit more and realized you can't set any default value, it's not limited to just null. Updating the issue now. |
Can also confirm this:
|
Seconding this. As we don't have mandatory typing, and we'll probably never have the need for Option or something like it, I feel that this is feature is a must. |
Still happens in Godot 3.2 beta2 |
Godot version: 3.1 beta 10
Issue description:
The above script causes an error on line 4 (the function definition):
Value type (null) doesn't match the type of argument 'parameter' (parameter)
.Line 7 causes a similar error.
If
parameter
is statically typed as any built-in class instead, it works fine. It's only for script-defined classes that the error appears.The text was updated successfully, but these errors were encountered: