Skip to content
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: Fix implicit cast to typed array when passing parameter #94025

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions modules/gdscript/gdscript_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,22 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
return _get_default_variant_for_data_type(return_type);
}
if (argument_types[i].kind == GDScriptDataType::BUILTIN) {
Variant arg;
Variant::construct(argument_types[i].builtin_type, arg, &p_args[i], 1, r_err);
memnew_placement(&stack[i + 3], Variant(arg));
if (argument_types[i].builtin_type == Variant::ARRAY && argument_types[i].has_container_element_type(0)) {
const GDScriptDataType &arg_type = argument_types[i].container_element_types[0];
Array array(p_args[i]->operator Array(), arg_type.builtin_type, arg_type.native_type, arg_type.script_type);
memnew_placement(&stack[i + 3], Variant(array));
} else {
Variant variant;
Variant::construct(argument_types[i].builtin_type, variant, &p_args[i], 1, r_err);
if (unlikely(r_err.error)) {
r_err.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_err.argument = i;
r_err.expected = argument_types[i].builtin_type;
call_depth--;
return _get_default_variant_for_data_type(return_type);
}
memnew_placement(&stack[i + 3], Variant(variant));
}
} else {
memnew_placement(&stack[i + 3], Variant(*p_args[i]));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# GH-93990

func test_param(array: Array[String]) -> void:
print(array.get_typed_builtin() == TYPE_STRING)

func test() -> void:
test_param(PackedStringArray())
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GDTEST_OK
true
Loading