swc-project/swc · error · Error
Expected whitespace, ';', '@', ident or EOF
Error message
Expected whitespace, ';', '@', ident or EOF
What it means
Fires in the declaration-or-at-rule parser when the current token cannot start a declaration or an at-rule. Per CSS Syntax Level 3, this is a parse error: the parser reconsumes the token and discards component values until a semicolon or EOF, recording this error so the invalid rule content is dropped rather than aborting the whole stylesheet.
Source
Thrown at crates/swc_css_parser/src/parser/syntax/mod.rs:563
temporary_list.span = span!(self, span.lo);
DeclarationOrAtRule::ListOfComponentValues(Box::new(temporary_list))
}
};
declarations.push(decl_or_list_of_component_values);
}
// anything else
// This is a parse error. Reconsume the current input token. As long as the next
// input token is anything other than a <semicolon-token> or <EOF-token>, consume a
// component value and throw away the returned value.
//
// We don't throw away the return value because of the recovery mode and return list
// of components values in this case
_ => {
let span = self.input.cur_span();
self.errors.push(Error::new(
span,
ErrorKind::Expected("whitespace, ';', '@', ident or EOF"),
));
// For recovery mode
let mut list_of_component_values = ListOfComponentValues {
span: Default::default(),
children: Vec::new(),
};
while !is_one_of!(self, ";", EOF) {
let component_value = self.parse_as::<ComponentValue>()?;
list_of_component_values.children.push(component_value);
}
list_of_component_values.span = span!(self, span.lo);
View on GitHub (pinned to 5176682b65)
Solutions
- Start declarations with a valid property ident or '@' for at-rules
- Check for stray tokens (stray delimiters, unclosed strings) before the offending position
- Remove or quote malformed content inside the rule block
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/syntax/mod.rs:563 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/0051447e6d036291.
Report an issue: GitHub.