{"record":{"id":"4478b1b636d26b30","repo":"slint-ui/slint","slug":"repeated-item-tree-must-have-a-parent","errorCode":null,"errorMessage":"repeated item_tree must have a parent","messagePattern":"repeated item_tree must have a parent","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/llr/item_tree.rs","lineNumber":338,"sourceCode":"        ctx: &EvaluationContext<'a, T>,\n    ) -> Option<ResolvedModelTwoWayBinding<'a>> {\n        let index_prop = self.is_model?;\n        let MemberReference::Relative { parent_level, local_reference } = &self.prop2 else {\n            unreachable!(\"model two-way binding's prop2 is always a Relative reference\")\n        };\n        debug_assert!(local_reference.sub_component_path.is_empty());\n        let LocalMemberIndex::Property(data_prop) = local_reference.reference else {\n            unreachable!(\"model two-way binding's prop2 always references a property\")\n        };\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","sourceCodeStart":320,"sourceCodeEnd":356,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/llr/item_tree.rs#L320-L356","documentation":"After resolving the parent chain for a repeated item's model two-way binding, the final parent is required to exist so its `repeater_index` can be read. A missing parent means the repeated item_tree was compiled without a parent link it was expected to have.","triggerScenarios":"A `for` loop body at the root level (or with an unpreserved parent chain) declares a two-way model binding that requires a parent sub-component context that does not exist.","commonSituations":"Using model two-way bindings inside top-level repeats without the enclosing sub-component structure the lowering expects; compiler regressions in item_tree parent tracking.","solutions":["Check that the `for` loop with the two-way model binding lives inside a sub-component with a parent chain","Ensure the item_tree lowering preserves parent links for repeated roots","File a compiler bug with a minimal .slint repro if the code is valid"],"exampleFix":"// .slint — before\ncomponent Root { for x in model: Rect { property <int> i <=> model.data; } }\n// after\nwrap the repeated element in a sub-component so a parent chain exists for the binding","handlingStrategy":"validation","validationCode":"if ctx.current_scope_parent().is_none() { return Err(\"two-way model binding requires an enclosing sub-component\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Place model two-way bindings inside sub-components with parents","Keep item_tree lowering tests covering repeated roots"],"tags":["rust","compiler","panic","repeater","item-tree"],"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"}