godot icon indicating copy to clipboard operation
godot copied to clipboard

GDScript: Fix object iterator opcodes

Open dalexeev opened this issue 3 months ago • 1 comments

  • Fixes #89290.

See core methods for reference:

https://github.com/godotengine/godot/blob/7abe0c6014022874378cb64a11b26b0f0f178324/core/variant/variant_setget.cpp#L1304-L1924

dalexeev avatar Mar 18 '24 11:03 dalexeev

There are some weird errors on the CI tests though, not sure what's going on.

vnen avatar Apr 25 '24 23:04 vnen

There are some weird errors on the CI tests though, not sure what's going on.

  • See #91120.

dalexeev avatar Apr 26 '24 05:04 dalexeev

To fix #74686 and #91155 I added the following:

@@ -2998,11 +2998,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
 				VariantInternal::initialize(&vref, Variant::ARRAY);
 				*VariantInternal::get_array(&vref) = ref;
 
-				Variant **args = instruction_args; // Overriding an instruction argument, but we don't need access to that anymore.
-				args[0] = &vref;
+				const Variant *args[] = { &vref };
 
 				Callable::CallError ce;
-				Variant has_next = obj->callp(CoreStringNames::get_singleton()->_iter_init, (const Variant **)args, 1, ce);
+				Variant has_next = obj->callp(CoreStringNames::get_singleton()->_iter_init, args, 1, ce);
 
 #ifdef DEBUG_ENABLED
 				if (ref.size() != 1 || ce.error != Callable::CallError::CALL_OK) {
@@ -3332,11 +3331,10 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
 				VariantInternal::initialize(&vref, Variant::ARRAY);
 				*VariantInternal::get_array(&vref) = ref;
 
-				Variant **args = instruction_args; // Overriding an instruction argument, but we don't need access to that anymore.
-				args[0] = &vref;
+				const Variant *args[] = { &vref };
 
 				Callable::CallError ce;
-				Variant has_next = obj->callp(CoreStringNames::get_singleton()->_iter_next, (const Variant **)args, 1, ce);
+				Variant has_next = obj->callp(CoreStringNames::get_singleton()->_iter_next, args, 1, ce);
 
 #ifdef DEBUG_ENABLED
 				if (ref.size() != 1 || ce.error != Callable::CallError::CALL_OK) {

dalexeev avatar Apr 26 '24 06:04 dalexeev

Thanks!

akien-mga avatar Apr 26 '24 09:04 akien-mga