[Bug]: @babel/plugin-transform-regenerator doesn't bind const in inner loop #15594
Labels
i: needs triage
outdated
A closed issue/PR that is archived due to age. Recommended to make a new issue
馃捇
How are you using Babel?
@babel/cli
Input code
REPL
Configuration file name
No response
Configuration
Current and expected behavior
Current behaviour: the compiled script writes
bar
.Expected behaviour (that is what you get if you run it unprocessed): the script writes
foo
.Output code
Environment
System:
OS: macOS 13.1
Binaries:
Node: 16.19.0 - ~/.nodenv/versions/16.19.0/bin/node
Yarn: 1.22.19 - ~/.nodenv/versions/16.19.0/bin/yarn
npm: 8.19.3 - ~/.nodenv/versions/16.19.0/bin/npm
npmPackages:
@babel/cli: ~7.21.0 => 7.21.0
Possible solution
const
in regenerated loops should not be converted tovars
blindly. Rather, the loops should be converted to ad-hoc functions (see how Facebooks regenerator does that).Additional context
Facebook regenerator handles this case properly:
The text was updated successfully, but these errors were encountered: