bevyengine/bevy · error

Attempted to apply a non-`Array` type to an `Array` type.

Error message

Attempted to apply a non-`Array` type to an `Array` type.

What it means

Panic in array_apply (used by PartialReflect::apply for arrays): the value being applied is not a reflected array (its ReflectRef is not ReflectRef::Array). Only reflected array values may be applied to an array.

Source

Thrown at crates/bevy_reflect/src/array.rs:421

/// Applies the reflected [array](Array) data to the given [array](Array).
///
/// # Panics
///
/// * Panics if the two arrays have differing lengths.
/// * Panics if the reflected value is not a [valid array](ReflectRef::Array).
#[inline]
pub fn array_apply<A: Array + ?Sized>(array: &mut A, reflect: &dyn PartialReflect) {
    if let ReflectRef::Array(reflect_array) = reflect.reflect_ref() {
        if array.len() != reflect_array.len() {
            panic!("Attempted to apply different sized `Array` types.");
        }
        for (i, value) in reflect_array.iter().enumerate() {
            let v = array.get_mut(i).unwrap();
            v.apply(value);
        }
    } else {
        panic!("Attempted to apply a non-`Array` type to an `Array` type.");
    }
}

/// Tries to apply the reflected [array](Array) data to the given [array](Array) and
/// returns a Result.
///
/// # Errors
///
/// * Returns an [`ApplyError::DifferentSize`] if the two arrays have differing lengths.
/// * Returns an [`ApplyError::MismatchedKinds`] if the reflected value is not a
///   [valid array](ReflectRef::Array).
/// * Returns any error that is generated while applying elements to each other.
#[inline]
pub fn array_try_apply<A: Array>(
    array: &mut A,
    reflect: &dyn PartialReflect,
) -> Result<(), ApplyError> {
    let reflect_array = reflect.reflect_ref().as_array()?;

View on GitHub (pinned to 8d743eb7dc)

Solutions

  1. Pass a value that reflects as an Array
  2. Use try_apply to receive a MismatchedKinds error instead of panicking
  3. Check reflect_ref() kind before applying
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/bevy_reflect/src/array.rs:419 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bevyengine/bevy@8d743eb7dc (2026-08-20). Data as JSON: /api/errors/964e2aadb8383b5b. Report an issue: GitHub.