swc-project/swc · error · swc_css_parser::Error

Expected ident (with 'and' value) token

Error message

Expected ident (with 'and' value) token

What it means

Fired while parsing a @supports condition's `and` operand: the parser expected the current token to be the ident `and` (case-insensitive) to build a SupportsAnd node, but another token was found. Input at fault is an @supports condition that continues with something other than the required `and` conjunction.

Source

Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:1071

            condition: supports_in_parens,
        })
    }
}

impl<I> Parse<SupportsAnd> for Parser<I>
where
    I: ParserInput,
{
    fn parse(&mut self) -> PResult<SupportsAnd> {
        let span = self.input.cur_span();
        let keyword = match cur!(self) {
            Token::Ident { value, .. } if value.as_ref().eq_ignore_ascii_case("and") => {
                let ident: Ident = self.parse()?;

                Some(ident)
            }
            _ => {
                return Err(Error::new(
                    span,
                    ErrorKind::Expected("ident (with 'and' value) token"),
                ));
            }
        };

        self.input.skip_ws();

        let supports_in_parens = self.parse()?;

        Ok(SupportsAnd {
            span: span!(self, span.lo),
            keyword,
            condition: supports_in_parens,
        })
    }
}

View on GitHub (pinned to 5176682b65)

Solutions

  1. Separate @supports conditions with the `and` ident
  2. Collect parser errors and report them
  3. Fix the condition syntax
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/swc_css_parser/src/parser/at_rules/mod.rs:1071 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/1a19ea703e5fbad3. Report an issue: GitHub.