swc-project/swc · error · swc_css_parser::Error
Expected declaration in parens
Error message
Expected declaration in parens
What it means
Inside a @supports parenthesized feature, try_to_parse_declaration_in_parens returned None — the content of the parentheses is neither a valid declaration nor a condition — so the parser reports this error at the current span.
Source
Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:1182
}
impl<I> Parse<SupportsFeature> for Parser<I>
where
I: ParserInput,
{
fn parse(&mut self) -> PResult<SupportsFeature> {
match cur!(self) {
tok!("(") => {
bump!(self);
self.input.skip_ws();
let declaration = match self.try_to_parse_declaration_in_parens() {
Some(declaration) => declaration,
None => {
let span = self.input.cur_span();
return Err(Error::new(
span,
ErrorKind::Expected("declaration in parens"),
));
}
};
expect!(self, ")");
Ok(SupportsFeature::Declaration(Box::new(declaration)))
}
Token::Function { value, .. }
if matches_eq_ignore_ascii_case!(&**value, "selector") =>
{
// TODO improve me
let ctx = Ctx {
in_supports_at_rule: true,
..self.ctx
};View on GitHub (pinned to 5176682b65)
Solutions
- Write a valid declaration such as (display: flex) inside the parens
- Report the diagnostic from collected errors
- Fix the @supports feature query
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:1182 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/83e7db9f8dcc14c8.
Report an issue: GitHub.