slint-ui/slint · error
repeated item_tree must have a parent
Error message
repeated item_tree must have a parent
What it means
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.
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
Example fix
// .slint — before
component Root { for x in model: Rect { property <int> i <=> model.data; } }
// after
wrap the repeated element in a sub-component so a parent chain exists for the binding Defensive patterns
Strategy: validation
Validate before calling
if ctx.current_scope_parent().is_none() { return Err("two-way model binding requires an enclosing sub-component"); } Prevention
- Place model two-way bindings inside sub-components with parents
- Keep item_tree lowering tests covering repeated roots
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- parent_level should be valid
- repeated parent has a repeater_index
- a setter belongs to a field
- an identifier
- default value requested for unknown struct field
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/4478b1b636d26b30.
Report an issue: GitHub.
Appendix: source
Thrown at internal/compiler/llr/item_tree.rs:338
ctx: &EvaluationContext<'a, T>,
) -> Option<ResolvedModelTwoWayBinding<'a>> {
let index_prop = self.is_model?;
let MemberReference::Relative { parent_level, local_reference } = &self.prop2 else {
unreachable!("model two-way binding's prop2 is always a Relative reference")
};
debug_assert!(local_reference.sub_component_path.is_empty());
let LocalMemberIndex::Property(data_prop) = local_reference.reference else {
unreachable!("model two-way binding's prop2 always references a property")
};
let super::EvaluationScope::SubComponent(mut sc, mut par) = ctx.current_scope else {
unreachable!("model two-way binding cannot be in a global")
};
for _ in 0..*parent_level {
let x = par.expect("parent_level should be valid");
par = x.parent;
sc = x.sub_component;
}
let par = par.expect("repeated item_tree must have a parent");
let data_prop_ty = &ctx.compilation_unit.sub_components[sc].properties[data_prop].ty;
Some(ResolvedModelTwoWayBinding {
parent_level: *parent_level,
body_sub_component: sc,
data_prop,
data_prop_ty,
index_prop,
parent_sub_component: par.sub_component,
repeater_index: par.repeater_index.expect("repeated parent has a repeater_index"),
})
}
}
#[derive(Debug, Default, Clone)]
pub struct Property {
pub name: SmolStr,
pub ty: Type,
/// The amount of time this property is used of another propertyView on GitHub (pinned to 3a7e700487)