You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior
Switch statements containing closures are generating broken code causing adjacent cases to run. See this minimal reproduction with the default settings:
Hey @mbostock! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."
Thanks for the report! I'm marking this as "help wanted" - maybe some volunteer will jump into fixing this before the core team manages to do it. I believe the solution using if statements seems like the easier one.
Bug Report
Current behavior
Switch statements containing closures are generating broken code causing adjacent cases to run. See this minimal reproduction with the default settings:
https://babeljs.io/en/repl#?browsers=defaults&build=&builtIns=false&spec=false&loose=false&code_lz=GYewTgBAFAxiB2BnALhAhhEwIG0CMAugJQQDeAUBBIgO4CWyMAFtMmAK4CmJFVVMaRJwhsuALjKU-_BCggAjCAF4IeANxTpUEkoB8CjdKp1sUUdwVhOaANaGjceMjrwu9qgF9NEAUIjA0ABshCV4jZCYwEBoIeE4YgFEwKLAoACJ2eCs0ZjR5QM40oncIL09yLyA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=env%2Creact%2Cstage-2%2Cenv&prettier=false&targets=&version=7.10.4&externalPlugins=
Input Code
Output Code
Expected behavior
No error is thrown (the break statement functions as intended, and the false case does not run).
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Defaults. See the REPL.
Environment
Defaults. See the REPL.
Possible Solution
If you want to use a
break
statement here, it needs to be a labeled break to break the outer loop.Alternatively, use an if instead of a nested switch.
The text was updated successfully, but these errors were encountered: