{"record":{"id":"3d2f686e8ac55d7b","repo":"leptos-rs/leptos","slug":"list-of-slots-must-not-be-empty","errorCode":null,"errorMessage":"List of slots must not be empty","messagePattern":"List of slots must not be empty","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"leptos_macro/src/view/component_builder.rs","lineNumber":265,"sourceCode":"                }\n            } else {\n                quote_spanned! {children.span()=>\n                    .children({\n                        #(#clonables)*\n\n                        ::leptos::children::ToChildren::to_children(move || #children)\n                    })\n                }\n            }\n        } else {\n            quote! {}\n        }\n    };\n\n    let slots = slots.drain().map(|(slot, mut values)| {\n        let span = values\n            .last()\n            .expect(\"List of slots must not be empty\")\n            .span();\n        let slot = Ident::new(&slot, span);\n        let value = if values.len() > 1 {\n            quote_spanned! {span=>\n                ::std::vec![\n                    #(#values)*\n                ]\n            }\n        } else {\n            values.remove(0)\n        };\n\n        quote! { .#slot(#value) }\n    });\n\n    let generics = &node.open_tag.generics;\n    let generics = if generics.lt_token.is_some() {\n        quote! { ::#generics }","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/leptos_macro/src/view/component_builder.rs#L247-L283","documentation":"In the view! macro's component builder, when a component invocation contains slot parameters, the macro drains a map of slot names to token values and calls values.last().expect(\"List of slots must not be empty\") to get a span. This panics if the slot map somehow contains a key with an empty values list, indicating an internal invariant violation while parsing slot assignments in the component call.","triggerScenarios":"Using <Component> with a <Bind:{slot} children=...>-style slot syntax (or custom slot syntax) that produces an empty values vector, typically via unusual/empty slot markup or macro-version-specific parsing edge cases.","commonSituations":"Macro/version mismatches between leptos_macro and leptos; copy-pasted slot syntax from another framework (e.g. children props written oddly); empty slot blocks like <slot /> inside a component in a form the parser mishandles.","solutions":["Write slots in the documented form: <Child slot:name>...</Child> inside the component, ensuring each slot has content/values","Remove empty or malformed slot markup from the component invocation","Align leptos and leptos_macro versions (update via cargo update -p leptos so the macro matches the runtime)","Reduce the view! to a minimal case and report the parsing edge case upstream if the syntax looks valid"],"exampleFix":"// before (empty/malformed slot)\nview! { <Card> <slot /> </Card> }\n// after\nview! { <Card> <CardHeader slot:name> <h1>\"Title\"</h1> </CardHeader> </Card> }","handlingStrategy":"validation","validationCode":"// Static check in a test: every <Comp> invocation in view! uses documented slot syntax\n// (grep CI check for '<slot' or empty slot children inside component calls)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the documented <Child slot:name>...</Child> slot syntax only","Never emit empty slot elements inside component invocations","Keep leptos_macro and leptos on the same version","If a panic appears with seemingly valid syntax, minimize the view! and file an upstream issue"],"tags":["view-macro","slots","compile-time","macro","panic"],"backgroundTag":"view-macro-slot-parse-failure","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}