{"record":{"id":"a5f16211fcbd5dcc","repo":"swc-project/swc","slug":"unknown-compound-assignment-operator","errorCode":null,"errorMessage":"unknown compound assignment operator","messagePattern":"unknown compound assignment operator","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_compat_es2015/src/generator.rs","lineNumber":666,"sourceCode":"                    // 4. Convert compound assignment to normal assignment\n                    let bin_op = match node.op {\n                        op!(\"+=\") => op!(bin, \"+\"),\n                        op!(\"-=\") => op!(bin, \"-\"),\n                        op!(\"*=\") => op!(\"*\"),\n                        op!(\"/=\") => op!(\"/\"),\n                        op!(\"%=\") => op!(\"%\"),\n                        op!(\"**=\") => op!(\"**\"),\n                        op!(\"<<=\") => op!(\"<<\"),\n                        op!(\">>=\") => op!(\">>\"),\n                        op!(\">>>=\") => op!(\">>>\"),\n                        op!(\"&=\") => op!(\"&\"),\n                        op!(\"|=\") => op!(\"|\"),\n                        op!(\"^=\") => op!(\"^\"),\n                        op!(\"&&=\") => op!(\"&&\"),\n                        op!(\"||=\") => op!(\"||\"),\n                        op!(\"??=\") => op!(\"??\"),\n                        _ => {\n                            unreachable!(\"unknown compound assignment operator\")\n                        }\n                    };\n\n                    *e = AssignExpr {\n                        span: node.span,\n                        op: op!(\"=\"),\n                        left: target,\n                        right: BinExpr {\n                            span: DUMMY_SP,\n                            op: bin_op,\n                            left: cached_value.into(),\n                            right: node.right.take(),\n                        }\n                        .into(),\n                    }\n                    .into();\n                } else {\n                    node.right.visit_mut_with(self);","sourceCodeStart":648,"sourceCodeEnd":684,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_compat_es2015/src/generator.rs#L648-L684","documentation":"While converting functions into regenerator-style state machines, the es2015 generator pass must rewrite compound assignments (e.g. `a += b`) into read-op-write sequences and maps each compound AssignOp to its binary counterpart. The match exhaustively lists every compound operator (`%= **= <<= >>= >>>= &= |= ^= &&= ||= ??=`); the unreachable! arm fires only for an AssignOp outside that set, which the parser can never produce.","triggerScenarios":"A corrupted or hand-constructed AST (via FFI, serde round-trip, or a custom transform) carrying an invalid/unknown AssignOp discriminant inside a generator function; or a swc_ecma_ast version that added a new assignment operator without a matching update in swc_ecma_compat_es2015::generator.","commonSituations":"wasm/FFI bindings deserializing an AST produced by a different swc version; unit tests synthesizing AssignExpr nodes by hand; upgrading swc_ecma_ast ahead of the compat crates.","solutions":["If you build ASTs programmatically or via FFI/serde, audit how AssignExpr.op is constructed and use the op!() macros so only valid operators appear.","Make sure swc_ecma_ast, swc_ecma_compat_es2015 and swc_core are the same release line (cargo tree -i swc_ecma_ast).","If the input is plain parsed source, report an swc bug with a minimal repro (the arm is unreachable from the parser)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// If you synthesize AssignExpr nodes, validate the operator first\nfn valid_compound_op(op: AssignOp) -> bool {\n    matches!(op, op!(\"%=\") | op!(\"**=\") | op!(\"<<=\") | op!(\">>=\") | op!(\">>>=\")\n        | op!(\"&=\") | op!(\"|=\") | op!(\"^=\") | op!(\"&&=\") | op!(\"||=\") | op!(\"??=\"))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build AST nodes with the op!() macros so only real operators exist.","Never round-trip ASTs through serde/FFI across mismatched swc versions.","Update swc_ecma_ast and compat crates together."],"tags":["swc","compat-es2015","generator","regenerator","compound-assignment","ast-invariant","panic"],"backgroundTag":"compiler-internal-panic","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}