swc-project/swc · error

Expected something like {} Got wrong meta tag: {:?}

Error message

Expected something like {}
Got wrong meta tag: {:?}

What it means

The #[fixture(...)] attribute from swc's testing_macros expands into one #[test] per file matched by a glob, and its Config::parse accepts exactly: a string-literal glob pattern, optionally followed by comma-separated exclude("regex") entries. The first token is parsed as LitStr (so it must be a quoted string); any subsequent meta element that is not an exclude(...) list falls through to unimplemented!("Expected something like ...\nGot wrong meta tag: ...") — a compile-time panic that prints the expected form.

Source

Thrown at crates/testing_macros/src/fixture.rs:70

                    }

                    let input = parse2::<InputParen>(list.tokens.clone())
                        .expect("failed to parse token as `InputParen`");

                    for lit in input.input {
                        c.exclude_patterns
                            .push(Regex::new(&lit.value()).unwrap_or_else(|err| {
                                fail!(format!("failed to parse regex: {}\n{}", lit.value(), err))
                            }));
                    }

                    return;
                }
            }

            let expected = r#"#[fixture("fixture/**/*.ts", exclude("*\.d\.ts"))]"#;

            unimplemented!(
                "Expected something like {}\nGot wrong meta tag: {:?}",
                expected,
                meta,
            )
        }

        let pattern: LitStr = input.parse()?;
        let pattern = pattern.value();

        let mut config = Self {
            pattern,
            exclude_patterns: Vec::new(),
        };

        let comma: Option<Token![,]> = input.parse()?;
        if comma.is_some() {
            let meta: Meta = input.parse()?;
            update(&mut config, meta);

View on GitHub (pinned to 5176682b65)

Solutions

  1. Quote the glob pattern as a string literal: #[fixture("tests/fixture/**/*.ts")].
  2. Express exclusions only as exclude("regex") with string-literal regexes: #[fixture("...", exclude(".*\\.d\\.ts"))].
  3. List multiple exclusions inside one exclude() as comma-separated strings rather than repeating the meta.
  4. Compare against the canonical example printed in the panic message: #[fixture("fixture/**/*.ts", exclude("*\\.d\\.ts"))].

Example fix

// before: compile-time panic 'Expected something like #[fixture(...)]'
#[fixture(tests/fixture/**/*.ts)]
#[fixture("tests/**", exclude = ".*\\.snap")]

// after
#[fixture("tests/fixture/**/*.ts", exclude(".*\\.d\\.ts", ".*\\.snap"))]
Defensive patterns

Strategy: validation

Validate before calling

# CI: flag #[fixture(...)] attributes whose first argument is not a quoted string literal
rg -nP '#\[fixture\(\s*[^" )]' crates --glob '*.rs' \
  && { echo 'malformed #[fixture] first argument (must be a quoted glob)'; exit 1; } || true

Prevention

When it happens

Trigger: Writing #[fixture(tests/fixture/**/*.ts)] with an unquoted glob, or any second argument that is not exclude("...") — e.g. #[fixture("...", include("..."))], #[fixture("...", exclude = "...")], or a name=value meta. Only `#[fixture("glob", exclude("re", ...))]` parses.

Common situations: Adding fixture suites to swc-family crates; copy-pasting from tests that use different macro conventions; assuming exclude accepts identifiers or unquoted regexes; escaping mistakes in the regex making authors try alternate syntaxes.

Related errors


AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17). Data as JSON: /api/errors/332601e957f86fd2. Report an issue: GitHub.