{"record":{"id":"ccabae308e8421a6","repo":"swc-project/swc","slug":"attempted-to-use-private-field-on-non-instance","errorCode":null,"errorMessage":"attempted to use private field on non-instance","messagePattern":"attempted to use private field on non-instance","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_base/src/helpers/generated/_class_private_field_loose_base.rs","lineNumber":12,"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_field_loose_base,\n    local: \"_class_private_field_loose_base\",\n    import_path: \"@swc/helpers/_/_class_private_field_loose_base\",\n    #[cfg(feature = \"inline-helpers\")]\n    source: r#\"function _class_private_field_loose_base(receiver, privateKey) {\n    if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {\n        throw new TypeError(\"attempted to use private field on non-instance\");\n    }\n\n    return receiver;\n}\n\"#,\n    #[cfg(feature = \"inline-helpers\")]\n    deps: super::HelperBitmap::from_bits(0x00000000000000000000000008000000),\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":28,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_base/src/helpers/generated/_class_private_field_loose_base.rs#L1-L28","documentation":"After the root element is closed the parser enters the End phase. Comments and processing instructions are legal there, but a CDATA section is not, so this arm both reports ErrorKind::UnexpectedTokenInEndPhase and still appends the CDATA node to the document (best-effort recovery). The error carries the CDATA span.","triggerScenarios":"A `<![CDATA[...]]>` block appearing after the closing tag of the root element, e.g. `<root/><![CDATA[trailing]]>`, typically from concatenating a fragment that starts with CDATA onto a complete document.","commonSituations":"Appending raw payload chunks after a serialized document; templating that emits CDATA-wrapped scripts after the document body; split files where the second part begins with CDATA and is glued to the first part's completed root.","solutions":["Move the CDATA section inside the root element where character data is permitted.","If the trailing CDATA came from concatenation, stop concatenating complete documents and merge at the node/tree level instead.","Delete the trailing block if it is accidental boilerplate.","Use the error span to locate which of several trailing blocks is the offender."],"exampleFix":"<!-- before: CDATA after root -->\n<doc/>\n<![CDATA[trailing data]]>\n\n<!-- after -->\n<doc>\n  <![CDATA[trailing data]]>\n</doc>","handlingStrategy":"validation","validationCode":"use swc_xml_parser::error::ErrorKind;\n\nlet mut errors = Vec::new();\nswc_xml_parser::parse_file_as_document(&fm, config, &mut errors)?;\nlet bad = errors.iter().any(|e| {\n    matches!(e.kind(), ErrorKind::UnexpectedTokenInEndPhase)\n});\nif bad {\n    return Err(\"content found after the root element\".into());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap multi-part payloads in a container element instead of appending CDATA after the root.","Run generated output through xmllint in CI to catch trailing junk."],"tags":["xml","parser","cdata","trailing-content","swc","recoverable"],"backgroundTag":"malformed-xml-document","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"}