{"record":{"id":"1b49ccf9ae183697","repo":"DioxusLabs/dioxus","slug":"selector-that-was-created-to-match-read-after-v","errorCode":null,"errorMessage":"Selector that was created to match {} read after variant changed","messagePattern":"Selector that was created to match (.+?) read after variant changed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/stores-macro/src/derive.rs","lineNumber":395,"sourceCode":"    field_index: usize,\n    field_count: usize,\n) -> TokenStream2 {\n    // When we map the field, we need to use either the field name for named fields or the index for unnamed fields.\n    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,","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/stores-macro/src/derive.rs#L377-L413","documentation":"A selector generated by the stores derive macro for a specific enum variant field was read after the store's active variant changed. The selector's lens still points at the old variant's field, which no longer exists in the current data, so reading it panics.","triggerScenarios":"Thrown at packages/stores-macro/src/derive.rs:395 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["A selector created for one enum variant was read after the variant changed. Re-create the selector after changing variants, or match before reading."],"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"}