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

Typed Array append_array type validation checks the argument's container type, not the contained type #54939

Closed
briansemrau opened this issue Nov 13, 2021 · 7 comments · Fixed by #62077
Milestone

Comments

@briansemrau
Copy link
Contributor

briansemrau commented Nov 13, 2021

Godot version

4.0.dev ()

System information

W10

Issue description

When using typed array append_array, I got a strange error.

E 0:00:06:0791   ContainerTypeValidate::validate: Attempted to append_array a variable of type 'Array' into a TypedArray of type 'Vector3i'.
  <C++ Error>    Condition "type != p_variant.get_type()" is true. Returning: false
  <C++ Source>   C:\Users\brian\Documents\GitHub\mygodot4\core\variant\container_type_validate.h:82 @ ContainerTypeValidate::validate()
E 0:00:06:0813   Array::append_array: Condition "!_p->typed.validate(p_array._p->typed.type, "append_array")" is true.
  <C++ Source>   core\variant\array.cpp:236 @ Array::append_array()

The issue that the validation done in append_array incorrectly checks the argument array's type (Variant::ARRAY) rather than the contained type (in this case, Variant::VECTOR3I).

void Array::append_array(const Array &p_array) {
ERR_FAIL_COND(!_p->typed.validate(p_array, "append_array"));
_p->array.append_array(p_array._p->array);
}

Steps to reproduce

var typed: Array[Vector3i] = []
var other: Array[Vector3i] = [Vector3i.ZERO]

typed.append_array(other)

Minimal reproduction project

No response

@h0lley
Copy link

h0lley commented Feb 22, 2022

I am getting this error in 4.0.alpha3 when using find_nodes().

E 0:00:00:0707   _ready: Attempted to append_array a variable of type 'Array' into a TypedArray of type 'Object'.
  <C++ Error>    Condition "type != p_variant.get_type()" is true. Returning: false
  <C++ Source>   core/variant/container_type_validate.h:82 @ validate()
  <Stack Trace>  test.gd:12 @ _ready()

only occurs when find_nodes() finds at least one item.
nothing I can do about it since it appears to be caused by find_nodes() internally.
it still works though.

@valentinAlkan
Copy link

Getting this same error with find_nodes. However, in my case, it can only actually find nodes that are one level below, regardless of the value of the recursive parameter.

@h0lley
Copy link

h0lley commented Mar 13, 2022

I am also getting this error even when calling append_array() on two arrays both obtained via get_children().

var cg1 = $Node2D.get_children()
var cg2 = $Node2D2.get_children()
cg1.append_array(cg2)
E 0:00:00:0685   _ready: Attempted to append_array a variable of type 'Array' into a TypedArray of type 'Object'.
  <C++ Error>    Condition "type != p_variant.get_type()" is true. Returning: false
  <C++ Source>   core/variant/container_type_validate.h:82 @ validate()
  <Stack Trace>  test.gd:18 @ _ready()
E 0:00:00:0685   _ready: Condition "!_p->typed.validate(p_array, "append_array")" is true.
  <C++ Source>   core/variant/array.cpp:236 @ append_array()
  <Stack Trace>  test.gd:18 @ _ready()

append_array() fails.

no amount of trying to statically type or cast the arrays to be the same type helps.

tested in alpha 1 and 4.

edit: interestingly array + array, or array += array seems to work just fine.

@voylin
Copy link
Contributor

voylin commented May 4, 2022

Any updates on this issue? I'm getting same errors whilst trying to fix the Physics Demo.

@h0lley
Copy link

h0lley commented May 4, 2022

Any updates on this issue? I'm getting same errors whilst trying to fix the Physics Demo.

have you read & tried this?

edit: interestingly array + array, or array += array seems to work just fine.

@lyuma
Copy link
Contributor

lyuma commented Jun 12, 2022

Also happens when double clicking a glb file to show the importer dialog:

ERROR: Attempted to append_array a variable of type 'Array' into a TypedArray of type 'Object'.
   at: (S:\repo\godot-fire\core\variant\container_type_validate.h:82)
ERROR: Condition "!_p->typed.validate(p_array, "append_array")" is true.
   at: Array::append_array (core\variant\array.cpp:263)

@lucasthomaz97
Copy link

E 0:00:08:0370 Spawner.gd:21 @ _process(): Attempted to find a variable of type 'String' into a TypedArray of type 'Object'. <Erro C++> Method/function failed. Returning: false <Origem C++> core/variant/container_type_validate.h:97 @ validate() <Rastreamento de Pilha>Spawner.gd:21 @ _process()
i'm checking if a string is on an array and i'm receiving the same error message. this is my code:
if !path in arr_child and path != "": to_respawn.append(path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants