{"record":{"id":"84845f4623ef07e6","repo":"bevyengine/bevy","slug":"variant-type-mismatch-expected-expected-rece","errorCode":null,"errorMessage":"variant type mismatch: expected {expected:?}, received {received:?}","messagePattern":"variant type mismatch: expected (.+?), received (.+?)","errorType":"exception","errorClass":"VariantInfoError","httpStatus":null,"severity":"error","filePath":"crates/bevy_reflect/src/enums/variants.rs","lineNumber":47,"sourceCode":"    /// ```\n    Tuple,\n    /// Unit enums take the form:\n    ///\n    /// ```\n    /// enum MyEnum {\n    ///   A\n    /// }\n    /// ```\n    Unit,\n}\n\n/// A [`VariantInfo`]-specific error.\n#[derive(Debug, Error)]\npub enum VariantInfoError {\n    /// Caused when a variant was expected to be of a certain [type], but was not.\n    ///\n    /// [type]: VariantType\n    #[error(\"variant type mismatch: expected {expected:?}, received {received:?}\")]\n    TypeMismatch {\n        /// Expected variant type.\n        expected: VariantType,\n        /// Received variant type.\n        received: VariantType,\n    },\n}\n\n/// A container for compile-time enum variant info.\n#[derive(Clone, Debug)]\npub enum VariantInfo {\n    /// Struct enums take the form:\n    ///\n    /// ```\n    /// enum MyEnum {\n    ///   A {\n    ///     foo: usize\n    ///   }","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_reflect/src/enums/variants.rs#L29-L65","documentation":"VariantInfoError::TypeMismatch — a check on an enum's VariantInfo expected the variant to be a certain VariantType (Struct/Tuple/Unit) but found another. The expected and received variant types are in the fields; callers should match on the actual variant type.","triggerScenarios":"Thrown at crates/bevy_reflect/src/enums/variants.rs:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Match on the actual VariantType before constructing or using VariantInfo","Fix the expected variant type to match the enum definition"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}