# eslint prefer-exponentiation-operator: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: eslint 9.39.5
- Rule: prefer-exponentiation-operator (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): real, severity high. The program redefines `Math.pow` to perform addition, so `Math.pow(2, 3)` returns 5. The fix replaces the call with `2 ** 3`, which uses the built-in exponentiation operator and returns 8. The documentation presents the rewrite as equivalent but does not account for a shadowed or reassigned `Math.pow`, making the fix unsafe for this plausible construct.
- Program: minimized from 7 to 4 lines

## Reproducer

```js
Math.pow = function(base, exp) { return base + exp; };
console.log(Math.pow(2, 3));
while (depth < 1) {
}
```

## Commands

```sh
node prog.js
npx eslint --no-config-lookup --rule 'prefer-exponentiation-operator: error' --fix prog.js
node prog.js
```

## Observed

```
stdout before:
5
stdout after:
8
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 14:27:11.709405001 -0400
+++ fixed.js	2026-10-22 14:27:13.774371035 -0400
@@ -1,4 +1,4 @@
 Math.pow = function(base, exp) { return base + exp; };
-console.log(Math.pow(2, 3));
+console.log(2**3);
 while (depth < 1) {
 }
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original code overrides `Math.pow` to add its arguments instead of performing exponentiation, so `Math.pow(2, 3)` evaluates to `5`. The ESLint fix replaces this call with the exponentiation operator `2**3`, which computes `8` using JavaScript’s built-in exponentiation semantics. Since the override changes the behavior of `Math.pow`, substituting it with the native operator alters the program’s output, making the rewrite not semantics-preserving under the modified environment. The fix assumes `Math.pow` behaves as specified, which is violated here.

## Upstream search

Queries: "prefer-exponentiation-operator fix", "prefer exponentiation operator call expression", "eslint prefer-exponentiation-operator math pow usage", "replace Math.pow calls with ** operator"

- related: https://github.com/eslint/eslint/issues/21319
  same rule prefer-exponentiation-operator but different construct (async function expression vs Math.pow call with numeric literals)

<details><summary>All hits</summary>

- [github, closed] Bug: prefer-exponentiation-operator autofix produces invalid syntax for an async function expression — https://github.com/eslint/eslint/issues/21319
- [github, closed] Bug: [yoda] autofix breaks code when the flipped comparison starts a statement — https://github.com/eslint/eslint/issues/21421
- [github, closed] Change Request: autoformat docs — https://github.com/eslint/eslint/issues/17504
- [github, closed] Change Request: (Add new config eslint/fixable containing all fixable rules) — https://github.com/eslint/eslint/issues/18027
- [github, closed] Change Request: track dependencies of eslint.config.js to invalidate cache & typescript support — https://github.com/eslint/eslint/issues/18337
- [github, closed] Bug: [new config system] path to a directory lints files outside that directory — https://github.com/eslint/eslint/issues/16260
- [github, closed] Update rules to support ES2022 class fields — https://github.com/eslint/eslint/issues/14857
- [github, closed] Bug: eslint fails to parse empty array types in typescript — https://github.com/eslint/eslint/issues/15551
- [github, closed] update eslint:recommended and eslint-config-eslint. — https://github.com/eslint/eslint/issues/14673
- [github, closed] Throws "is assigned but never used" even though its used for jsdoc — https://github.com/eslint/eslint/issues/15019
- [github, closed] Docs: rewrite examples with `var` using `const` and `let` — https://github.com/eslint/eslint/issues/19240
- [github, closed] Docs: Clearly mark rules that are frozen — https://github.com/eslint/eslint/issues/18694
- [github, closed] Bug: eslint is running absurdly slow for a few small files — https://github.com/eslint/eslint/issues/15728
- [github, closed] No support for recursion. — https://github.com/eslint/eslint/issues/15008

</details>
