slint-ui/slint · error

repeated parent has a repeater_index

Error message

repeated parent has a repeater_index

What it means

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.

Solutions

  1. Ensure the two-way model data binding is inside the `for` loop whose model it references
  2. Verify the parent-chain resolution keeps `repeater_index` populated for repeated parents
  3. Isolate the .slint snippet and file a compiler bug if the construct is valid

Example fix

// .slint — before
two-way binding to model data placed outside the for-loop body
// after
move `property <T> item <=> model[current-index];` inside the `for` body
Defensive patterns

Strategy: validation

Validate before calling

if par.repeater_index.is_none() { return Err("model data binding requires a repeated parent context"); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16). Data as JSON: /api/errors/276286683bed496f. Report an issue: GitHub.

Appendix: source

Thrown at internal/compiler/llr/item_tree.rs:347

        };
        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 property
    /// This property is only valid after the [`count_property_use`](super::optim_passes::count_property_use) pass
    pub use_count: Cell<usize>,
}

#[derive(Debug, Default, Clone)]
pub struct Callback {
    pub name: SmolStr,
    pub ret_ty: Type,
    pub args: Vec<Type>,

View on GitHub (pinned to 3a7e700487)