swc-project/swc · error · Error
Expected Ident
Error message
Expected Ident
What it means
Fired while parsing a CustomIdent: the current token was not an Ident, so no CSS-wide-keyword-excluded custom identifier could be produced. The `if !is!(self, Ident)` check is a validation guard; input at fault is a context expecting a custom ident (e.g. a counter style name, keyframes name) that receives a number, string, or other token.
Source
Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:1829
value,
raw: Some(raw),
}),
_ => {
unreachable!()
}
}
}
}
impl<I> Parse<CustomIdent> for Parser<I>
where
I: ParserInput,
{
fn parse(&mut self) -> PResult<CustomIdent> {
let span = self.input.cur_span();
if !is!(self, Ident) {
return Err(Error::new(span, ErrorKind::Expected("Ident")));
}
match bump!(self) {
Token::Ident { value, raw, .. } => {
if matches_eq_ignore_ascii_case!(
value, "initial", "inherit", "unset", "revert", "default"
) {
return Err(Error::new(span, ErrorKind::InvalidCustomIdent(value)));
}
Ok(CustomIdent {
span,
value,
raw: Some(raw),
})
}
_ => {
unreachable!()View on GitHub (pinned to 5176682b65)
Solutions
- Provide an identifier token where a custom ident is expected
- Quote strings explicitly if a string was intended
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:1829 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/80b4652373822ed6.
Report an issue: GitHub.