swc-project/swc · error

{}\nnote: exclude() expects one or more comma-separated regu

Error message

{}\nnote: exclude() expects one or more comma-separated regular expressions, like exclude(".*\\.d\\.ts") or exclude(".*\\.d\\.ts", ".*\\.tsx")

What it means

A macro-input validation error in the Parse impl for Config in swc_testing_macros (fixture.rs:41). When parsing the `exclude(...)` list of the #[fixture] attribute, any malformed token (wrong meta shape, non-string values, bad punctuation) triggers the inner fail! macro, which panics with 'invalid input to the attribute' and this note explaining that exclude expects one or more comma-separated regex strings like exclude(".*\\.d\\.ts"). The malformed attribute token stream is the input at fault.

Source

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

}

impl Parse for Config {
    fn parse(input: ParseStream) -> syn::Result<Self> {
        fn update(c: &mut Config, meta: Meta) {
            if let Meta::List(list) = &meta {
                if list
                    .path
                    .get_ident()
                    .map(|i| *i == "exclude")
                    .unwrap_or(false)
                {
                    //
                    macro_rules! fail {
                        () => {{
                            fail!("invalid input to the attribute")
                        }};
                        ($inner:expr) => {{
                            panic!(
                                "{}\nnote: exclude() expects one or more comma-separated regular \
                                 expressions, like exclude(\".*\\\\.d\\\\.ts\") or \
                                 exclude(\".*\\\\.d\\\\.ts\", \".*\\\\.tsx\")",
                                $inner
                            )
                        }};
                    }

                    if list.tokens.is_empty() {
                        fail!("empty exclude()")
                    }

                    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| {

View on GitHub (pinned to 5176682b65)

Solutions

  1. Rewrite the exclude() argument as one or more comma-separated string literals containing regexes
  2. Use raw strings or double-escape backslashes in regex literals (e.g. ".*\\.d\\.ts")
  3. Return a syn::Error with span instead of panicking so rustc points at the offending token
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/testing_macros/src/fixture.rs:41 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/7b3d0dd038b2b65a. Report an issue: GitHub.