fix(regenerator): handle destructuring hoist crash in async (#17517)#17877
Open
Vikash9546 wants to merge 1 commit intobabel:mainfrom
Open
fix(regenerator): handle destructuring hoist crash in async (#17517)#17877Vikash9546 wants to merge 1 commit intobabel:mainfrom
Vikash9546 wants to merge 1 commit intobabel:mainfrom
Conversation
…7517) Regenerator's hoist pass assumed VariableDeclarator ids are always Identifiers. When async-to-generator runs without transform-destructuring, destructuring patterns can reach regenerator and crash while generating hoisted vars. Made-with: Cursor
Collaborator
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61187 |
JLHwung
requested changes
Mar 17, 2026
| @@ -0,0 +1,34 @@ | |||
| import { transformSync } from "@babel/core"; | |||
Contributor
There was a problem hiding this comment.
In general we embrace fixture-based test cases for plugin behaviour: See https://github.com/babel/babel/blob/main/CONTRIBUTING.md#writing-tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When running
@babel/plugin-transform-async-to-generatorfollowed by@babel/plugin-transform-regenerator, async code containing untransformed destructuring can crash with:Property name expected type of string but got undefinedRepro from
#17517:Cause
Regenerator's
hoistpass assumed everyVariableDeclaratorhas anIdentifierid, and useddec.id.namewhen collecting vars. With destructuring,dec.idis a pattern sonameisundefined, triggering the@babel/typesinvariant.Solution
Collect binding identifiers via
getBindingIdentifiers(dec.id)instead of assumingIdentifier, so patterns are supported and the transform no longer crashes.Tests
packages/babel-plugin-transform-regenerator/test/regression-17517.js).Fixes #17517