{"record":{"id":"ab2a710bdeba7582","repo":"swc-project/swc","slug":"right-associative-binary-expression","errorCode":null,"errorMessage":"right-associative binary expression","messagePattern":"right-associative binary expression","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_compat_es2015/src/generator.rs","lineNumber":506,"sourceCode":"                    let alt_span = node.cons.span();\n                    node.alt.visit_mut_with(self);\n                    self.emit_assignment(\n                        result_local.clone().into(),\n                        node.alt.take(),\n                        Some(alt_span),\n                    );\n\n                    self.mark_label(result_label);\n\n                    *e = result_local.into();\n                } else {\n                    node.visit_mut_with(self);\n                }\n            }\n\n            Expr::Bin(node) => {\n                if node.op == op!(\"**\") {\n                    todo!(\"right-associative binary expression\")\n                } else {\n                    let new = self.visit_left_associative_bin_expr(node);\n                    if let Some(new) = new {\n                        *e = new;\n                    }\n                }\n            }\n\n            Expr::Seq(node) => {\n                //     // flattened version of `visitCommaExpression`\n                let mut pending_expressions = Vec::new();\n\n                for mut elem in node.exprs.take() {\n                    if let Expr::Seq(mut elem) = *elem {\n                        elem.visit_mut_with(self);\n                        pending_expressions.extend(elem.exprs.take());\n                    } else {\n                        if contains_yield(&elem) && !pending_expressions.is_empty() {","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_compat_es2015/src/generator.rs#L488-L524","documentation":"This is a Rust todo!() panic in the ES2015 generator-lowering pass (swc_ecma_compat_es2015). While rewriting a function containing yield into a state machine, the transform special-cases binary expressions: left-associative operators are lowered via visit_left_associative_bin_expr, but the exponentiation operator ** is right-associative and its lowering logic has not been implemented yet, so hitting a ** expression inside a generator function aborts compilation with an 'internal error: entered unreachable code' style panic. The input at fault is any `a ** b` (or nested `a ** b ** c`) expression occurring within a generator function body that this compat pass is processing.","triggerScenarios":"Thrown at crates/swc_ecma_compat_es2015/src/generator.rs:506 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rewrite the generator to compute the exponentiation with Math.pow(a, b) instead of the ** operator, so the transform never encounters a right-associative BinExpr","Move the ** expression out of the generator function into a separate (non-generator) helper that is called from the generator","Run the swc_exponentiation_operator (ES2016) transform before the ES2015 generator pass so ** is already rewritten to Math.pow by the time generator lowering runs","If you control the compiler configuration, ensure the correct ordering of compat passes (exponentiation before generators) in the SWC pass pipeline"],"exampleFix":null,"handlingStrategy":"fallback","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"}