@@ -1805,15 +1805,17 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
18051805 const StringName native_type = _global_names_ptr[native_type_idx];
18061806
18071807 Array array;
1808+ array.set_typed (builtin_type, native_type, *script_type);
18081809 array.resize (argc);
18091810 for (int i = 0 ; i < argc; i++) {
1810- array[i] = *(instruction_args[i]);
1811+ // Use .set instead of operator[] to handle type conversion / validation.
1812+ array.set (i, *(instruction_args[i]));
18111813 }
18121814
18131815 GET_INSTRUCTION_ARG (dst, argc);
18141816 *dst = Variant (); // Clear potential previous typed array.
18151817
1816- *dst = Array ( array, builtin_type, native_type, *script_type) ;
1818+ *dst = array;
18171819
18181820 ip += 4 ;
18191821 }
@@ -1864,18 +1866,20 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
18641866 const StringName value_native_type = _global_names_ptr[value_native_type_idx];
18651867
18661868 Dictionary dict;
1869+ dict.set_typed (key_builtin_type, key_native_type, *key_script_type, value_builtin_type, value_native_type, *value_script_type);
18671870
18681871 for (int i = 0 ; i < argc; i++) {
18691872 GET_INSTRUCTION_ARG (k, i * 2 + 0 );
18701873 GET_INSTRUCTION_ARG (v, i * 2 + 1 );
1871- dict[*k] = *v;
1874+ // Use .set instead of operator[] to handle type conversion / validation.
1875+ dict.set (*k, *v);
18721876 }
18731877
18741878 GET_INSTRUCTION_ARG (dst, argc * 2 );
18751879
18761880 *dst = Variant (); // Clear potential previous typed dictionary.
18771881
1878- *dst = Dictionary ( dict, key_builtin_type, key_native_type, *key_script_type, value_builtin_type, value_native_type, *value_script_type) ;
1882+ *dst = dict;
18791883
18801884 ip += 6 ;
18811885 }
0 commit comments