swc-project/swc · error

failed parse args

Error message

failed parse args

What it means

In parse_args of swc_ecma_codegen_macros, the macro's argument token stream could not be parsed as a non-empty Punctuated list of the expected elements. This fires during expansion of the codegen emit macros when the arguments do not match the expected comma-separated grammar — e.g. empty or malformed arguments — while fold_macro builds emit_node_inner! invocations.

Source

Thrown at crates/swc_ecma_codegen_macros/src/lib.rs:107

                .into_pairs()
                .flat_map(|arg| arg.into_token_stream())
                .collect();

            let is_emit = self.emit;
            i = parse_quote!(emit_node_inner!(emitter, #is_emit, #args));
        }

        i
    }
}

fn parse_args<T, P>(tokens: TokenStream) -> Punctuated<T, P>
where
    T: Parse,
    P: Parse + Token,
{
    let parser = Punctuated::parse_separated_nonempty;
    parser.parse2(tokens).expect("failed parse args")
}

View on GitHub (pinned to 5176682b65)

Solutions

  1. Check the macro invocation's arguments form a valid comma-separated non-empty list
  2. Remove stray or unbalanced tokens (extra commas, unmatched braces)
  3. Reduce complex nested macro calls in the arguments to plain expressions
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/swc_ecma_codegen_macros/src/lib.rs:107 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/de9ce31db8467b22. Report an issue: GitHub.