{"record":{"id":"22070541ba477d90","repo":"slint-ui/slint","slug":"internal-compiler-error-more-than-one-strong-refe","errorCode":null,"errorMessage":"internal compiler error: more than one strong reference left to repeated component when lowering shadow properties","messagePattern":"internal compiler error: more than one strong reference left to repeated component when lowering shadow properties","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/object_tree.rs","lineNumber":5184,"sourceCode":"        .unwrap();\n        let expr_v =\n            BindingExpression::new_with_span(expr_v, old_root.borrow().to_source_location());\n        li_v.element().borrow_mut().set_binding(li_v.name().clone(), expr_v);\n        let expr_h =\n            BindingExpression::new_with_span(expr_h, old_root.borrow().to_source_location());\n        li_h.element().borrow_mut().set_binding(li_h.name().clone(), expr_h);\n        Some((li_h.clone(), li_v.clone()))\n    });\n    new_root.borrow_mut().layout_info_prop = layout_info_prop;\n    forward_layout_info_with_constraint(&new_root, old_root);\n\n    // Replace the repeated component's element with our shadow element. That requires a bit of reference counting\n    // surgery and relies on nobody having a strong reference left to the component, which we take out of the Rc.\n    drop(std::mem::take(&mut repeated_element.borrow_mut().base_type));\n\n    debug_assert_eq!(Rc::strong_count(&component), 1);\n\n    let mut component = Rc::try_unwrap(component).expect(\"internal compiler error: more than one strong reference left to repeated component when lowering shadow properties\");\n\n    let old_root = std::mem::replace(&mut component.root_element, new_root.clone());\n    new_root.borrow_mut().children.push(old_root);\n\n    let component = Rc::new(component);\n    repeated_element.borrow_mut().base_type = ElementType::Component(component.clone());\n\n    for elem in elements_with_enclosing_component_reference {\n        elem.borrow_mut().enclosing_component = Rc::downgrade(&component);\n    }\n}\n\n/// Make the geometry of the `injected_parent` that of the old_elem. And the old_elem\n/// will cover the `injected_parent`\npub fn adjust_geometry_for_injected_parent(injected_parent: &ElementRc, old_elem: &ElementRc) {\n    let mut injected_parent_mut = injected_parent.borrow_mut();\n    injected_parent_mut.set_binding(\n        \"z\".into(),","sourceCodeStart":5166,"sourceCodeEnd":5202,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/object_tree.rs#L5166-L5202","documentation":"This debug-guarded panic fires in the shadow-property lowering pass (object_tree.rs:5124). To graft the repeated component's root element under a shadow element, the code takes the `base_type` out of the repeated element and then `Rc::try_unwrap`s the component, requiring exactly one strong reference. If any other code still holds a strong `Rc` to the component, the compiler aborts with this message rather than corrupting the component.","triggerScenarios":"Compiling a `for`/repeated element with shadow properties (e.g. `for x in model: Foo { property <int> shadowed-prop: ...; }` patterns) while some other compiler structure — a cloned element, a second reference in the element tree, or a pass holding the component — retains a strong `Rc<Component>` reference.","commonSituations":"Compiler regressions in nightly builds around `Repeater`/repeated component lowering; .slint files using shadow properties on repeated elements that hit an untested code path; contributor changes to element cloning or component reference counting.","solutions":["Restructure the repeated component: move the shadow-property customization into the component's own declaration instead of redefining properties at the repetition site.","Test with the latest stable Slint release; if it passes, the nightly has a regression — downgrade.","Minimize the .slint file and report the bug with the reproducer.","For contributors: audit code paths that clone `ElementType::Component` values before the shadow-property pass runs and drop extra strong references."],"exampleFix":"// before\nfor item in model: MyComp { shadow-property-override: item.value; }\n// after\ncomponent MyComp inherits Base { property <int> shadow-property-override; }\nfor item in model: MyComp { shadow-property-override: item.value; }","handlingStrategy":"fallback","validationCode":"// Prefer explicit components over anonymous repeated components with shadow properties\nfn uses_shadow_properties_on_repeats(src: &str) -> bool {\n    src.contains(\"for \") && src.matches('{').count() > 0 // heuristic: review repeated elements manually\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare named components and set their properties at the repetition site instead of redefining properties inline.","Pin a known-good Slint version in CI for embedded builds.","Report reproducers quickly so regressions in repeated-component lowering get fixed."],"tags":["rust","compiler","internal-panic","reference-counting"],"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"}