{"record":{"id":"1fc39bcc41e02c3d","repo":"slint-ui/slint","slug":"constraint-must-have-binding","errorCode":null,"errorMessage":"constraint must have binding","messagePattern":"constraint must have binding","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/passes/default_geometry.rs","lineNumber":349,"sourceCode":"                    p.clone(),\n                    Expression::StructFieldAccess {\n                        base: Expression::ReadLocalVariable {\n                            name: unique_name.clone(),\n                            ty: ty.clone(),\n                        }\n                        .into(),\n                        name: p.clone(),\n                    },\n                )\n            })\n            .collect::<BTreeMap<_, _>>();\n\n        for (nr, s) in constraints.for_each_restrictions(orientation) {\n            let e = nr\n                .element()\n                .borrow()\n                .binding(nr.name())\n                .expect(\"constraint must have binding\")\n                .expression\n                .clone();\n            debug_assert!(!matches!(e, Expression::Invalid));\n            values.insert(s.into(), e);\n        }\n        *expr = Expression::CodeBlock([store, Expression::Struct { ty: s.clone(), values }].into());\n    }\n}\n\nfn explicit_layout_info(e: &ElementRc, orientation: Orientation) -> Expression {\n    let mut values = BTreeMap::new();\n    let (size, orient) = match orientation {\n        Orientation::Horizontal => (\"width\", \"horizontal\"),\n        Orientation::Vertical => (\"height\", \"vertical\"),\n    };\n    for (k, v) in [\n        (\"min\", format_smolstr!(\"min-{size}\")),\n        (\"max\", format_smolstr!(\"max-{size}\")),","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/compiler/passes/default_geometry.rs#L331-L367","documentation":"This panic fires in `merge_explicit_constraints` (internal/compiler/passes/default_geometry.rs:345), called from `gen_layout_info_prop` while generating layout info for elements with explicit layout constraints. For each restriction the code fetches the element's binding for the constraint property (e.g. `min-width`, `preferred-height`) and asserts a binding exists. A missing binding means a constraint was registered in the layout analysis without an actual property binding — an inconsistent compiler state.","triggerScenarios":"Compiling a layout (Row/Column/GridLayout or a component with explicit min/max/preferred size constraints) where a restriction was recorded for an element/property pair whose binding was removed or never created — e.g. constraints set on elements without real bindings, bindings consumed/cleared by an earlier pass, or two-way binding edge cases.","commonSituations":"Nightly compiler regressions in default geometry; .slint layouts combining percentage/implicit sizes with explicit constraints in unusual ways; contributor changes to binding creation or constraint collection.","solutions":["Set explicit layout constraints directly with property bindings (e.g. `min-width: 100px;`) rather than via intermediate indirections.","Test with the latest stable Slint compiler to rule out a regression; downgrade if a nightly fails.","Simplify the layout — split deeply nested or unusually constrained layouts into sub-components.","Contributors: verify `register_property_with_let`/constraint registration always creates a binding before `merge_explicit_constraints` reads it."],"exampleFix":"// before\nRectangle { width: parent.width * 0.5; } // implicit, no constraint binding\n// after\nRectangle { min-width: 100px; preferred-width: 200px; }","handlingStrategy":"validation","validationCode":"// Prefer real bindings for every constraint property you declare\nfn constraints_have_bindings(element_props: &[&str]) -> bool {\n    [\"min-width\", \"min-height\", \"max-width\", \"max-height\", \"preferred-width\", \"preferred-height\"]\n        .iter().all(|c| !element_props.contains(c) || true /* verify a binding exists for each declared constraint */)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare constraints as direct property bindings, not via computed/implicit values only.","Avoid mixing heavy implicit sizing with explicit constraints in one layout.","Test layouts against stable Slint releases in CI."],"tags":["rust","compiler","internal-panic","layout"],"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"}