bevyengine/bevy · error · ApplyError

`{from_type}` is not `{to_type}`

Error message

`{from_type}` is not `{to_type}`

What it means

ApplyError::MismatchedTypes — try_apply found the source and destination TypeId/paths incompatible after kind checks (applying a value of from_type onto a destination of to_type). Apply a value of the same concrete type as the destination.

Source

Thrown at crates/bevy_reflect/src/reflect.rs:41

    #[error("attempted to apply `{from_kind}` to `{to_kind}`")]
    /// Attempted to apply the wrong [kind](ReflectKind) to a type, e.g. a struct to an enum.
    MismatchedKinds {
        /// Kind of the value we attempted to apply.
        from_kind: ReflectKind,
        /// Kind of the type we attempted to apply the value to.
        to_kind: ReflectKind,
    },

    #[error("enum variant `{variant_name}` doesn't have a field named `{field_name}`")]
    /// Enum variant that we tried to apply to was missing a field.
    MissingEnumField {
        /// Name of the enum variant.
        variant_name: Box<str>,
        /// Name of the missing field.
        field_name: Box<str>,
    },

    #[error("`{from_type}` is not `{to_type}`")]
    /// Tried to apply incompatible types.
    MismatchedTypes {
        /// Type of the value we attempted to apply.
        from_type: Box<str>,
        /// Type we attempted to apply the value to.
        to_type: Box<str>,
    },

    #[error("attempted to apply type with {from_size} size to a type with {to_size} size")]
    /// Attempted to apply an [array-like] type to another of different size, e.g. a [u8; 4] to [u8; 3].
    ///
    /// [array-like]: crate::array::Array
    DifferentSize {
        /// Size of the value we attempted to apply, in elements.
        from_size: usize,
        /// Size of the type we attempted to apply the value to, in elements.
        to_size: usize,
    },

View on GitHub (pinned to 396ca72708)

Solutions

  1. Apply a value of the same type as the target
  2. Convert the value before applying
  3. Check reflect_type_path on both sides when debugging
Defensive patterns

Strategy: type-guard

When it happens

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

Common situations: See trigger scenarios.


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/588b8cd80d028deb. Report an issue: GitHub.