swc-project/swc · error · swc_css_parser::Error
Expected ident or string
Error message
Expected ident or string
What it means
Fired while parsing the name of a @keyframes at-rule: the current token was neither an ident nor a string, so no valid keyframes name (a <custom-ident> or a <string>) could be produced. Input at fault is @keyframes with a missing or malformed name, e.g. `@keyframes { ... }` or `@keyframes 2x { ... }`.
Source
Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:906
}
}
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)))
}
tok!("string") => Ok(KeyframesName::Str(Box::new(self.parse()?))),
_ => {
let span = self.input.cur_span();
Err(Error::new(span, ErrorKind::Expected("ident or string")))
}
}
}
}
impl<I> Parse<KeyframeSelector> for Parser<I>
where
I: ParserInput,
{
fn parse(&mut self) -> PResult<KeyframeSelector> {
match cur!(self) {
tok!("ident") => {
let ident: Ident = self.parse()?;
let lower = ident.value.to_ascii_lowercase();
if lower != "from" && lower != "to" {
return Err(Error::new(
ident.span,View on GitHub (pinned to 5176682b65)
Solutions
- Give @keyframes a valid ident or string name
- Report the error from the parse result
- Fix the CSS source
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:906 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/3813a961b8711a20.
Report an issue: GitHub.