{"record":{"id":"a229aeb78f6d6472","repo":"DioxusLabs/dioxus","slug":"selector-that-was-created-to-match-written-afte","errorCode":null,"errorMessage":"Selector that was created to match {} written after variant changed","messagePattern":"Selector that was created to match (.+?) written after variant changed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/stores-macro/src/derive.rs","lineNumber":399,"sourceCode":"    let binding = function_name_from_field(field_index, field);\n    let field_type = &field.ty;\n    let pattern = if field.ident.is_none() {\n        let before = (0..field_index).map(|_| quote!(_));\n        let after = (field_index + 1..field_count).map(|_| quote!(_));\n        quote!( ( #(#before,)* #binding, #(#after),* ) )\n    } else {\n        quote!( { #binding, .. })\n    };\n    // Each field gets its own reactive scope within the child based on the field's index\n    let ordinal = LitInt::new(&field_index.to_string(), variant_name.span());\n    quote! {\n        let __map_field: fn(&#enum_name #ty_generics) -> &#field_type = |value| match value {\n            #enum_name::#variant_name #pattern => #binding,\n            _ => panic!(\"Selector that was created to match {} read after variant changed\", stringify!(#variant_name)),\n        };\n        let __map_mut_field: fn(&mut #enum_name #ty_generics) -> &mut #field_type = |value| match value {\n            #enum_name::#variant_name #pattern => #binding,\n            _ => panic!(\"Selector that was created to match {} written after variant changed\", stringify!(#variant_name)),\n        };\n        // Map the field into a child selector that tracks the field\n        let scope = self.into_selector().child(#ordinal, __map_field, __map_mut_field);\n        // Convert the selector into a store\n        ::std::convert::Into::into(scope)\n    }\n}\n\n// For enums, we derive two items:\n// - An extension trait with methods to check if the store is a specific variant and a method\n//   to access the field of that variant if there is only one field\n// - A transposed version of the enum with all fields wrapped in stores\nfn derive_store_enum(\n    input: &DeriveInput,\n    structure: &DataEnum,\n    extension_trait_name: Ident,\n    transposed_name: Ident,\n    extension_generics: Generics,","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/stores-macro/src/derive.rs#L381-L417","documentation":"A store selector bound to one enum variant's field was written after the store switched to a different variant. Writing through a stale lens would target a field that no longer exists, so the generated code guards with this panic.","triggerScenarios":"Thrown at packages/stores-macro/src/derive.rs:399 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["A selector created for one enum variant was written after the variant changed. Re-create the selector after changing variants, or match before writing."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}