{"record":{"id":"0b2e121b6302d534","repo":"swc-project/swc","slug":"json-subdiagnostic-d","errorCode":null,"errorMessage":"json subdiagnostic: {d:?}","messagePattern":"json subdiagnostic: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bindings/binding_nodejs_support_wasm/src/lib.rs","lineNumber":173,"sourceCode":"        let snippet = d.span.primary_span().and_then(|span| {\n            let mut snippet = String::new();\n            let reporter = self.reporter.get_or_insert_with(json_reporter);\n            match reporter.render_report(\n                &mut snippet,\n                &Snippet {\n                    source_code: &to_pretty_source_code(&self.cm, true),\n                    span,\n                },\n            ) {\n                Ok(()) => Some(snippet),\n                Err(_) => None,\n            }\n        });\n\n        let children = d\n            .children\n            .iter()\n            .map(|d| todo!(\"json subdiagnostic: {d:?}\"))\n            .collect::<Vec<_>>();\n\n        let error_code = match &d.code {\n            Some(DiagnosticId::Error(s)) => Some(&**s),\n            Some(DiagnosticId::Lint(s)) => Some(&**s),\n            None => None,\n        };\n\n        let start = d\n            .span\n            .primary_span()\n            .and_then(|span| self.cm.try_lookup_char_pos(span.lo()).ok());\n\n        let end = d\n            .span\n            .primary_span()\n            .and_then(|span| self.cm.try_lookup_char_pos(span.hi()).ok());\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/bindings/binding_nodejs_support_wasm/src/lib.rs#L155-L191","documentation":"An unreachable!() in the JSON diagnostic emit path (binding_nodejs_support_wasm lib.rs:173). While serializing a top-level diagnostic's sub-diagnostics (children), the code maps each child; the arm is reached only if the child list yields something the mapping code considers impossible for well-formed diagnostics from rustc/swc — i.e. a malformed sub-diagnostic structure. It marks a broken invariant in diagnostic construction rather than a user input error, and names the offending sub-diagnostic via {d:?}.","triggerScenarios":"Thrown at bindings/binding_nodejs_support_wasm/src/lib.rs:173 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the full parent diagnostic to see which sub-diagnostic shape broke the invariant","Ensure diagnostics are constructed via the swc_common diagnostic builders so children are always well-formed","Return an error from emit instead of panicking so the wasm binding can surface a JS-side failure"],"exampleFix":null,"handlingStrategy":"validation","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"}