swc-project/swc · error
failed to parse args of #[ast_node]
Error message
failed to parse args of #[ast_node]
What it means
On the non-enum arm of #[ast_node] (structs/unions), the attribute arguments failed to parse into ast_node_macro::Args. This fires when the payload after the node tag uses an unknown or malformed option — the expected forms are a quoted tag like #[ast_node("Ident")] plus recognized flags such as no_partial_eq; anything else fails at compile time.
Source
Thrown at crates/ast_node/src/lib.rs:260
)]
#clone
#non_exhaustive
#[cfg_attr(
feature = "serde-impl",
serde(untagged)
)]
#[cfg_attr(
feature = "encoding-impl",
derive(::swc_common::Encode, ::swc_common::Decode)
)]
#input
));
}
_ => {
let args: Option<ast_node_macro::Args> = if args.is_empty() {
None
} else {
Some(parse(args).expect("failed to parse args of #[ast_node]"))
};
let serde_tag = match input.data {
Data::Struct(DataStruct {
fields: Fields::Named(..),
..
}) => {
if args.is_some() {
Some(quote!(#[cfg_attr(
feature = "serde-impl",
serde(tag = "type")
)]))
} else {
None
}
}
_ => None,
};View on GitHub (pinned to 5176682b65)
Solutions
- Verify the arguments match the documented grammar, e.g. #[ast_node("Tag", no_partial_eq)]
- Remove unsupported options and check crate docs for the accepted flag list
- For enums, drop arguments entirely — the enum arm rejects them with its own message
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/ast_node/src/lib.rs:260 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/a112be28e2fabd79.
Report an issue: GitHub.