swc-project/swc · error · io::Error
unsupported
unsupported
Error message
emit unknown variant is not supported
What it means
Sentinel io::Error (ErrorKind::Unsupported) returned by the codegen when the swc_ast_unknown cfg is enabled and the AST contains an 'unknown' variant node that the emitter has no rendering rule for. It fires at emit time, meaning the input AST was constructed from a newer/unknown syntax variant.
Source
Thrown at crates/swc_ecma_codegen/src/lib.rs:2569
fn emit(&mut self, emitter: &mut Macro) -> Result {
emitter.emit_ident_like(self.span, &self.sym, self.optional)?;
Ok(())
}
}
#[node_impl]
impl MacroNode for IdentName {
fn emit(&mut self, emitter: &mut Macro) -> Result {
emitter.emit_ident_like(self.span, &self.sym, false)?;
Ok(())
}
}
#[cfg(swc_ast_unknown)]
fn unknown_error() -> io::Error {
io::Error::new(
io::ErrorKind::Unsupported,
"emit unknown variant is not supported",
)
}
View on GitHub (pinned to 5176682b65)
Solutions
- Ensure the parser/compiler that produced the AST and the codegen crate share the same swc_ecma_ast version so no unknown variants exist
- Handle io::ErrorKind::Unsupported at the call site and report it as an unsupported-syntax error to the user
- Do not enable the swc_ast_unknown cfg in builds that must serialize arbitrary ASTs
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/swc_ecma_codegen/src/lib.rs:2569 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/d4f852489d5de354.
Report an issue: GitHub.