{"record":{"id":"8a8ebb284bd31c74","repo":"slint-ui/slint","slug":"element-without-a-size","errorCode":null,"errorMessage":"element without a size","messagePattern":"element without a size","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/generator/slint_sc.rs","lineNumber":971,"sourceCode":"fn geometry_prop(\n    elem: &ElementRc,\n    ctx: &Ctx,\n    prop: fn(&GeometryProps) -> &NamedReference,\n) -> Option<TokenStream> {\n    let props = elem.borrow().geometry_props.clone();\n    compile_property_reference(prop(props.as_ref()?), ctx)\n}\n\n/// The compiled offset of an element from its parent.\nfn element_position(elem: &ElementRc, ctx: &Ctx) -> (TokenStream, TokenStream) {\n    let resolve = |prop| geometry_prop(elem, ctx, prop).unwrap_or_else(|| quote!(0i32));\n    (resolve(|g: &GeometryProps| &g.x), resolve(|g: &GeometryProps| &g.y))\n}\n\n/// The compiled size of an element. The default_geometry pass leaves a size\n/// binding on every element, and the root's size resolves to the window size.\nfn element_size(elem: &ElementRc, ctx: &Ctx) -> (TokenStream, TokenStream) {\n    let resolve = |prop| geometry_prop(elem, ctx, prop).expect(\"element without a size\");\n    (resolve(|g: &GeometryProps| &g.width), resolve(|g: &GeometryProps| &g.height))\n}\n\n/// Walk `elem` and its descendants, emitting for each a block that adds the\n/// element's position to the running `offset_x`/`offset_y`, whatever `body`\n/// makes of the element, and then the children's blocks — so that later and\n/// deeper elements come after earlier and shallower ones. A subtree `body`\n/// makes nothing of emits nothing, and compiles nothing either, so that its\n/// bindings make no coverage points.\n///\n/// Rendering and hit testing are the same walk, which is what makes a\n/// `TouchArea` sit exactly where it paints.\nfn emit_tree(\n    elem: &ElementRc,\n    ctx: &Ctx,\n    body: &mut dyn FnMut(&ElementRc) -> Option<TokenStream>,\n) -> TokenStream {\n    let statements = body(elem);","sourceCodeStart":953,"sourceCodeEnd":989,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/compiler/generator/slint_sc.rs#L953-L989","documentation":"`element_size` resolves an element's width/height binding via `geometry_prop`, which relies on the `default_geometry` compiler pass leaving a size binding on every element. The panic means an element reached codegen without a resolvable size binding.","triggerScenarios":"Compiling a .slint component where an element's width/height binding was not produced by `default_geometry` — e.g. running the slint-sc generator on a compilation unit that skipped that pass, or an element type the pass does not cover.","commonSituations":"Embedding the compiler in a tool and calling generator passes in the wrong order; adding a new builtin element and forgetting to teach `default_geometry` about its size.","solutions":["Ensure the `default_geometry` pass runs before slint-sc codegen","If you added a new element/builtin, teach `default_geometry` to emit a size binding for it","Inspect the element with the missing binding using `SLINT_DEBUG` or a debugger on `geometry_prop` and file a compiler bug with the .slint reproduction"],"exampleFix":"// before\nlet resolve = |prop| geometry_prop(elem, ctx, prop).expect(\"element without a size\");\n// after\nlet resolve = |prop| geometry_prop(elem, ctx, prop)\n    .ok_or_else(|| anyhow!(\"element {:?} has no size binding; ensure default_geometry ran\", elem.debug_id))?;","handlingStrategy":"validation","validationCode":"if geometry_prop(elem, ctx, |g: &GeometryProps| &g.width).is_none() {\n    return Err(\"element has no size binding; default_geometry pass missing or incomplete\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run passes in the documented order; default_geometry before slint-sc codegen","When adding builtins, extend default_geometry to cover their sizes"],"tags":["rust","compiler","panic","layout","codegen"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}