{"record":{"id":"3ec767715c6761d5","repo":"swc-project/swc","slug":"tocode-for","errorCode":null,"errorMessage":"ToCode for {}","messagePattern":"ToCode for (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_quote_macros/src/ast/mod.rs","lineNumber":11,"sourceCode":"use swc_common::{Span, SyntaxContext};\nuse swc_ecma_ast::*;\nuse syn::{parse_quote, ExprBlock};\n\nuse crate::ctxt::Ctx;\n\nmacro_rules! fail_todo {\n    ($T:ty) => {\n        impl crate::ast::ToCode for $T {\n            fn to_code(&self, _: &crate::ctxt::Ctx) -> syn::Expr {\n                todo!(\"ToCode for {}\", stringify!($T))\n            }\n        }\n    };\n}\n\nmacro_rules! impl_enum_body {\n    ($E:ident, $s:expr, $cx:expr,[ $($v:ident),* ]) => {\n        match $s {\n            $(\n                $E::$v(inner) => {\n                    let val = crate::ast::ToCode::to_code(inner, $cx);\n                    syn::parse_quote!(\n                        swc_core::ecma::ast::$E::$v(#val)\n                    )\n                },\n            )*\n            #[cfg(swc_ast_unknown)]\n            _ => panic!(\"unable to access unknown nodes\"),","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_quote_macros/src/ast/mod.rs#L1-L29","documentation":"A todo!() stub generated by the fail_todo! macro in swc_ecma_quote_macros (ast/mod.rs:11). For AST node types the quote-strings-to-code machinery has not implemented yet, the macro installs a ToCode impl that panics with 'ToCode for <Type>' when that node is quoted. It fires whenever a quoted expression contains an AST node kind lacking a real ToCode implementation; the node type named in the message is the gap.","triggerScenarios":"Thrown at crates/swc_ecma_quote_macros/src/ast/mod.rs:11 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Implement ToCode for the node type named in the panic message and contribute it upstream","Avoid quoting that node kind inside the quote macros until support exists","Check swc release notes — the missing ToCode impl may have been added in a newer version"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}