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

Expected 'from' or 'to' idents

Error message

Expected 'from' or 'to' idents

What it means

Fired while parsing a keyframe selector inside @keyframes: an ident token was read, but after case-insensitive comparison it was neither `from` nor `to`, and only those two idents are valid keyframe selectors (percentages are handled elsewhere). Input at fault is a selector like `@keyframes x { start { ... } }`.

Source

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

                Err(Error::new(span, ErrorKind::Expected("ident or string")))
            }
        }
    }
}

impl<I> Parse<KeyframeSelector> for Parser<I>
where
    I: ParserInput,
{
    fn parse(&mut self) -> PResult<KeyframeSelector> {
        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"),
                ));
            }
        }
    }

View on GitHub (pinned to 5176682b65)

Solutions

  1. Use `from`, `to`, or a percentage as the keyframe selector
  2. Collect parser errors for diagnostics
  3. Fix the @keyframes block
Defensive patterns

Strategy: validation

When it happens

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