swc-project/swc · error · swc_css_parser::Error
Expected ident or function (local or scope) token
Error message
Expected ident or function (local or scope) token
What it means
While parsing an at-rule name/prelude position, the parser found a token that is neither an ident nor the expected function form, so it reports this error at the current span. The source does not match the expected name grammar at that position.
Source
Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:883
{
let pseudo = self.parse()?;
self.input.skip_ws();
let name = self.parse()?;
Ok(KeyframesName::PseudoPrefix(Box::new(
KeyframesPseudoPrefix {
span: span!(self, span.lo),
pseudo,
name,
},
)))
}
_ => {
let span = self.input.cur_span();
Err(Error::new(
span,
ErrorKind::Expected("ident or function (local or scope) token"),
))
}
}
}
tok!("ident") => {
let custom_ident: CustomIdent = self.parse()?;
if matches_eq_ignore_ascii_case!(custom_ident.value, "none") {
return Err(Error::new(
custom_ident.span,
ErrorKind::InvalidCustomIdent(custom_ident.value),
));
}
Ok(KeyframesName::CustomIdent(Box::new(custom_ident)))
}View on GitHub (pinned to 5176682b65)
Solutions
- Write the name using an ident or the expected function form
- Report the error from the parse result
- Fix the CSS around the at-rule
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:883 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/72504363cac9a80f.
Report an issue: GitHub.