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

Expected ident at first position in <general-enclosed>

Error message

Expected ident at first position in <general-enclosed>

What it means

Fired while validating a <general-enclosed> in a @supports prelude: after parsing a parenthesized simple block, the parser scans its contents to confirm the first meaningful item is an Ident (a general-enclosed must look like `(ident ...)`); it is a generic validation guard and fires when the block starts with a non-ident token (e.g. a number or delimiter).

Source

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

            tok!("(") => {
                let block = self.parse_as::<SimpleBlock>()?;

                let mut found_ident = false;

                for component_value in &block.value {
                    match component_value {
                        ComponentValue::PreservedToken(token_and_span) => {
                            match token_and_span.token {
                                Token::WhiteSpace { .. } => {
                                    continue;
                                }
                                Token::Ident { .. } => {
                                    found_ident = true;

                                    break;
                                }
                                _ => {
                                    return Err(Error::new(
                                        block.span,
                                        ErrorKind::Expected(
                                            "ident at first position in <general-enclosed>",
                                        ),
                                    ));
                                }
                            }
                        }
                        _ => {
                            return Err(Error::new(
                                block.span,
                                ErrorKind::Expected(
                                    "ident at first position in <general-enclosed>",
                                ),
                            ));
                        }
                    }
                }

View on GitHub (pinned to 5176682b65)

Solutions

  1. Start the general-enclosed value with an ident
  2. Report the error from the parse result
  3. Fix the query syntax
Defensive patterns

Strategy: validation

When it happens

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