swc-project/swc · error · Error
Expected at least one name
Error message
Expected at least one name
What it means
Fired during @layer prelude canonicalization: the layer name list was empty even though the at-rule form requires at least one layer name (or a block-only '@layer { }' which is handled separately). The parser cannot attribute the rule to any layer and reports this error.
Source
Thrown at crates/swc_css_parser/src/parser/util.rs:113
at_rule.prelude = match self
.parse_according_to_grammar(&list_of_component_values, |parser| {
parser.parse_at_rule_prelude(&normalized_at_rule_name)
}) {
Ok(at_rule_prelude) => match at_rule_prelude {
Some(AtRulePrelude::LayerPrelude(LayerPrelude::NameList(name_list)))
if name_list.name_list.len() > 1 && at_rule.block.is_some() =>
{
self.errors.push(Error::new(
name_list.span,
ErrorKind::Expected("only one name"),
));
Some(Box::new(AtRulePrelude::ListOfComponentValues(
list_of_component_values,
)))
}
None if normalized_at_rule_name == "layer" && at_rule.block.is_none() => {
self.errors.push(Error::new(
at_rule.span,
ErrorKind::Expected("at least one name"),
));
Some(Box::new(AtRulePrelude::ListOfComponentValues(
list_of_component_values,
)))
}
_ => at_rule_prelude.map(Box::new),
},
Err(err) => {
if *err.kind() != ErrorKind::Ignore {
self.errors.push(err);
}
if !list_of_component_values.children.is_empty() {
Some(Box::new(AtRulePrelude::ListOfComponentValues(
list_of_component_values,View on GitHub (pinned to 5176682b65)
Solutions
- Provide at least one layer name: '@layer name;' or '@layer name { ... }'
- If an anonymous layer is intended, drop the prelude entirely: '@layer { ... }'
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/util.rs:113 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/8a3e1afc9c5db01b.
Report an issue: GitHub.