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

Expected 'from', 'to' or percentage

Error message

Expected 'from', 'to' or percentage

What it means

The parser could not match a keyframe selector: the current token is neither a `from`/`to` ident nor a percentage, so it reports this error. Common triggers are a bare number without `%` or an arbitrary ident.

Source

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

        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,
                        ErrorKind::Expected("'from' or 'to' idents"),
                    ));
                }

                Ok(KeyframeSelector::Ident(ident))
            }
            tok!("percentage") => Ok(KeyframeSelector::Percentage(self.parse()?)),
            _ => {
                let span = self.input.cur_span();

                return Err(Error::new(
                    span,
                    ErrorKind::Expected("'from', 'to' or percentage"),
                ));
            }
        }
    }
}

impl<I> Parse<FontFeatureValuesPrelude> for Parser<I>
where
    I: ParserInput,
{
    fn parse(&mut self) -> PResult<FontFeatureValuesPrelude> {
        let span = self.input.cur_span();

        let mut font_family = vec![self.parse()?];

        loop {

View on GitHub (pinned to 5176682b65)

Solutions

  1. Write selectors as from, to, or N%
  2. Surface the error from the parse result
  3. Fix the keyframes selector syntax
Defensive patterns

Strategy: validation

When it happens

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