{"record":{"id":"c18efe4b0394d96a","repo":"swc-project/swc","slug":"attempted-to-reassign-private-method","errorCode":null,"errorMessage":"attempted to reassign private method","messagePattern":"attempted to reassign private method","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_base/src/helpers/generated/_class_private_method_set.rs","lineNumber":11,"sourceCode":"// This file is generated by `cargo codegen helpers`. DO NOT MODIFY.\n\nuse super::{HelperDef, HelperName};\n\npub const DEF: HelperDef = HelperDef {\n    name: HelperName::class_private_method_set,\n    local: \"_class_private_method_set\",\n    import_path: \"@swc/helpers/_/_class_private_method_set\",\n    #[cfg(feature = \"inline-helpers\")]\n    source: r#\"function _class_private_method_set() {\n    throw new TypeError(\"attempted to reassign private method\");\n}\n\"#,\n    #[cfg(feature = \"inline-helpers\")]\n    deps: super::HelperBitmap::from_bits(0x00000000000000000000000200000000),\n};\n\n#[cfg(feature = \"inline-helpers\")]\npub fn stmts() -> &'static [swc_ecma_ast::Stmt] {\n    static STMTS: once_cell::sync::Lazy<Vec<swc_ecma_ast::Stmt>> =\n        once_cell::sync::Lazy::new(|| super::super::parse(DEF.source, DEF.import_path));\n    &STMTS\n}\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_base/src/helpers/generated/_class_private_method_set.rs#L1-L24","documentation":"In the End phase only comments, processing instructions, whitespace characters, and EOF are legal; everything else (a second start/empty tag, an end tag, or a doctype) falls into the `_` catch-all and is reported as ErrorKind::UnexpectedTokenInEndPhase. The token is then discarded - notably this is how a second root element is rejected, because XML permits exactly one.","triggerScenarios":"Two sibling root elements (`<a/><b/>`), an end tag with no matching open element (`</a>` twice), or a doctype after the root element. Any tag token arriving after the open-elements stack emptied and the phase switched to EndPhase.","commonSituations":"Concatenating multiple XML documents into one file (very common with logs or batch exports); templating loops that repeat the root element; copy-pasting a second document into an existing file; forgetting to wrap repeated items in a container element.","solutions":["Wrap all top-level content in a single root element so there is exactly one root.","Remove duplicate end tags or stray declarations after the root's closing tag.","If you must store many documents in one file, use a container element or a format that supports multiple roots (e.g. XML fragments with an external parser policy).","Use the error span to find the offset of the second root/tag and split the file there if it truly contains two documents."],"exampleFix":"<!-- before: two root elements -->\n<record id=\"1\"/>\n<record id=\"2\"/>\n\n<!-- after -->\n<records>\n  <record id=\"1\"/>\n  <record id=\"2\"/>\n</records>","handlingStrategy":"validation","validationCode":"use swc_xml_parser::error::ErrorKind;\n\nlet mut errors = Vec::new();\nlet doc = swc_xml_parser::parse_file_as_document(&fm, config, &mut errors)?;\nif errors\n    .iter()\n    .any(|e| matches!(e.kind(), ErrorKind::UnexpectedTokenInEndPhase))\n{\n    return Err(\"extra root element or stray tags at document end\".into());\n}\n// belt-and-braces: count element children of the document\nlet roots = doc\n    .children\n    .iter()\n    .filter(|c| matches!(c, swc_xml_ast::Child::Element(_)))\n    .count();\nassert_eq!(roots, 1, \"XML requires exactly one root element\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap repeated records in a container element when generating batches.","Split concatenated documents at parsing boundaries rather than feeding them as one file.","Assert single-root invariants on your own document builder types."],"tags":["xml","parser","multiple-roots","trailing-content","swc","recoverable"],"backgroundTag":"multiple-root-elements","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}