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

Expected '{' token

Error message

Expected '{' token

What it means

@font-face takes no prelude, only a block; the parser found tokens after @font-face that are not EOF and returns this error at the current span, indicating trailing junk where the { ... } block should begin.

Source

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

                    matching_functions.push(self.parse()?);
                }

                let prelude = AtRulePrelude::DocumentPrelude(DocumentPrelude {
                    span: span!(self, span.lo),
                    matching_functions,
                });

                self.input.skip_ws();

                Some(prelude)
            }
            "font-face" => {
                self.input.skip_ws();

                if !is!(self, EOF) {
                    let span = self.input.cur_span();

                    return Err(Error::new(span, ErrorKind::Expected("'{' token")));
                }

                None
            }
            "font-feature-values" => {
                self.input.skip_ws();

                let prelude = AtRulePrelude::FontFeatureValuesPrelude(self.parse()?);

                self.input.skip_ws();

                Some(prelude)
            }
            "font-palette-values" => {
                self.input.skip_ws();

                let prelude = AtRulePrelude::FontPaletteValuesPrelude(self.parse()?);

View on GitHub (pinned to 5176682b65)

Solutions

  1. Remove tokens after @font-face and supply its { ... } block
  2. Surface the returned error as a diagnostic
  3. Skip the malformed rule
Defensive patterns

Strategy: validation

When it happens

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