[GDScript] Fix `get_argument_count` for lambda `Callable`s
This commit is contained in:
parent
20ba2f00bd
commit
aa28782be3
|
@ -84,7 +84,7 @@ int GDScriptLambdaCallable::get_argument_count(bool &r_is_valid) const {
|
|||
return 0;
|
||||
}
|
||||
r_is_valid = true;
|
||||
return function->get_argument_count();
|
||||
return function->get_argument_count() - captures.size();
|
||||
}
|
||||
|
||||
void GDScriptLambdaCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
|
||||
|
@ -204,7 +204,7 @@ int GDScriptLambdaSelfCallable::get_argument_count(bool &r_is_valid) const {
|
|||
return 0;
|
||||
}
|
||||
r_is_valid = true;
|
||||
return function->get_argument_count();
|
||||
return function->get_argument_count() - captures.size();
|
||||
}
|
||||
|
||||
void GDScriptLambdaSelfCallable::call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# https://github.com/godotengine/godot/issues/93952
|
||||
|
||||
func foo():
|
||||
pass
|
||||
|
||||
func test():
|
||||
var a: int
|
||||
|
||||
var lambda_self := func (x: int) -> void:
|
||||
foo()
|
||||
print(a, x)
|
||||
|
||||
print(lambda_self.get_argument_count()) # Should print 1.
|
||||
|
||||
var lambda_non_self := func (x: int) -> void:
|
||||
print(a, x)
|
||||
|
||||
print(lambda_non_self.get_argument_count()) # Should print 1.
|
|
@ -0,0 +1,3 @@
|
|||
GDTEST_OK
|
||||
1
|
||||
1
|
Loading…
Reference in New Issue