{"record":{"id":"276286683bed496f","repo":"slint-ui/slint","slug":"repeated-parent-has-a-repeater-index","errorCode":null,"errorMessage":"repeated parent has a repeater_index","messagePattern":"repeated parent has a repeater_index","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/llr/item_tree.rs","lineNumber":347,"sourceCode":"        };\n        let super::EvaluationScope::SubComponent(mut sc, mut par) = ctx.current_scope else {\n            unreachable!(\"model two-way binding cannot be in a global\")\n        };\n        for _ in 0..*parent_level {\n            let x = par.expect(\"parent_level should be valid\");\n            par = x.parent;\n            sc = x.sub_component;\n        }\n        let par = par.expect(\"repeated item_tree must have a parent\");\n        let data_prop_ty = &ctx.compilation_unit.sub_components[sc].properties[data_prop].ty;\n        Some(ResolvedModelTwoWayBinding {\n            parent_level: *parent_level,\n            body_sub_component: sc,\n            data_prop,\n            data_prop_ty,\n            index_prop,\n            parent_sub_component: par.sub_component,\n            repeater_index: par.repeater_index.expect(\"repeated parent has a repeater_index\"),\n        })\n    }\n}\n\n#[derive(Debug, Default, Clone)]\npub struct Property {\n    pub name: SmolStr,\n    pub ty: Type,\n    /// The amount of time this property is used of another property\n    /// This property is only valid after the [`count_property_use`](super::optim_passes::count_property_use) pass\n    pub use_count: Cell<usize>,\n}\n\n#[derive(Debug, Default, Clone)]\npub struct Callback {\n    pub name: SmolStr,\n    pub ret_ty: Type,\n    pub args: Vec<Type>,","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/llr/item_tree.rs#L329-L365","documentation":"When constructing `ResolvedModelTwoWayBinding`, the resolved parent context must carry a `repeater_index` (it must come from inside a `for` loop). The panic fires when the parent has no repeater index, i.e. the data property's parent is not a repeated context.","triggerScenarios":"Declaring a two-way binding to a model data property where the resolved parent sub-component is not produced by a repeater, so `repeater_index` is None.","commonSituations":"Model two-way bindings (`property <X> v <=> model[i]` style patterns) written outside the repeated context the lowering assumes; regressions in how parent contexts are recorded during llr lowering.","solutions":["Ensure the two-way model data binding is inside the `for` loop whose model it references","Verify the parent-chain resolution keeps `repeater_index` populated for repeated parents","Isolate the .slint snippet and file a compiler bug if the construct is valid"],"exampleFix":"// .slint — before\ntwo-way binding to model data placed outside the for-loop body\n// after\nmove `property <T> item <=> model[current-index];` inside the `for` body","handlingStrategy":"validation","validationCode":"if par.repeater_index.is_none() { return Err(\"model data binding requires a repeated parent context\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only reference model data properties from within the corresponding for-loop body","Cover parent-context recording for repeaters with tests"],"tags":["rust","compiler","panic","repeater","model"],"backgroundTag":"internal-invariant-violation","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}