mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
Per ECMAScript Annex B, function declarations inside labeled statements
in sloppy mode should hoist like regular function declarations, not like
block-scoped functions.
Previously, Bun incorrectly transformed:
```js
foo:
function bar() { return "bar"; }
console.log(bar()); // ReferenceError: bar is not defined
```
Into:
```js
foo: {
let bar = function() { return "bar"; };
}
console.log(bar()); // bar is undefined outside the block
```
Now the function declaration is preserved as-is, matching Node.js/V8 behavior.
Fixes #25737
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>