{"record":{"id":"c90f63c0c44f7648","repo":"swc-project/swc","slug":"attempted-to-get-private-field-on-non-instance","errorCode":null,"errorMessage":"attempted to get private field on non-instance","messagePattern":"attempted to get private field on non-instance","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_base/src/helpers/generated/_class_private_method_get.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_get,\n    local: \"_class_private_method_get\",\n    import_path: \"@swc/helpers/_/_class_private_method_get\",\n    #[cfg(feature = \"inline-helpers\")]\n    source: r#\"function _class_private_method_get(receiver, privateSet, fn) {\n    if (!privateSet.has(receiver)) throw new TypeError(\"attempted to get private field on non-instance\");\n\n    return fn;\n}\n\"#,\n    #[cfg(feature = \"inline-helpers\")]\n    deps: super::HelperBitmap::from_bits(0x00000000000000000000000080000000),\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":26,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_base/src/helpers/generated/_class_private_method_get.rs#L1-L26","documentation":"In the Start and End phases (outside the root element) only whitespace character data is legal. When a Token::Character carries a non-whitespace value in the End phase, the parser records ErrorKind::UnexpectedCharacter (message: 'Unexpected character, only whitespace character allowed') with that character's span and otherwise ignores the text. The identical check exists in the Start phase arm just above.","triggerScenarios":"Any visible text after the root element's closing tag (or, via the Start-phase arm at line 281, before it): `<doc/>trailing`, stray punctuation, or formatting artifacts like a BOM-adjacent character or leftover markup fragments that the lexer tokenized as characters.","commonSituations":"Trailing debug prints or log lines appended after serialized XML; template footer text placed after the closing tag; concatenated documents; data whose final newline was followed by a stray character during manual editing; non-breaking space or other Unicode whitespace-classified-as-non-whitespace characters (the check uses the XML whitespace set: space, tab, CR, LF only).","solutions":["Go to the reported span and delete or relocate the non-whitespace text that sits outside the root element.","Wrap stray trailing content inside the root element if it is meaningful data.","Trim the document after serialization and ensure templates have no literal footer text.","Remember only U+0020, U+0009, U+000D, U+000A count as whitespace - replace fancy Unicode spaces with plain spaces."],"exampleFix":"<!-- before: text after root element -->\n<doc>ok</doc>\ntrailing junk\n\n<!-- after -->\n<doc>ok</doc>\n","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)?;\nif errors\n    .iter()\n    .any(|e| matches!(e.kind(), ErrorKind::UnexpectedCharacter))\n{\n    return Err(\"non-whitespace text outside the root element\".into());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim serializers' output and forbid template footers after the closing tag.","Remember the XML whitespace set is only space/tab/CR/LF - normalize Unicode spaces before writing."],"tags":["xml","parser","text-node","whitespace","swc","recoverable"],"backgroundTag":"text-outside-root-element","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"}