fix(runtime): align async iterator throw with Babel (#28059)

Async-from-sync `.throw(error)` currently looks up the sync iterator's `return` method. Change that lookup to `throw` in both CommonJS and ESM helpers, matching [Babel's implementation](https://github.com/babel/babel/blob/main/packages/babel-helpers/src/helpers/asyncIterator.ts).

The upstream `yield-star/throw-method-sync-iterator` regression added in #28057 now passes; update its execution snapshot. `just test-transform` reproduces the expected results: 320/418 Babel execution tests and 40/42 local execution tests, with no new failures. Direct delegation checks also pass for both helper formats.
This commit is contained in:
camc314 committed 2026-10-22 19:27:40 +00:00
1 parent af0258d583
commit e3eca411d5
3 files changed
+3 -11

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@ function AsyncFromSyncIterator(r) {
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
},
"throw": function _throw(r) {
var n = this.s["return"];
var n = this.s["throw"];
return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
}
}, new AsyncFromSyncIterator(r);
+1 -1
View File
@@ -37,7 +37,7 @@ function AsyncFromSyncIterator(r) {
}) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
},
"throw": function _throw(r) {
var n = this.s["return"];
var n = this.s["throw"];
return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
}
}, new AsyncFromSyncIterator(r);
@@ -2,7 +2,7 @@ commit: a56fe4a4
node: v26.12.1
Passed: 319 of 418 (76.32%)
Passed: 320 of 418 (76.56%)
Failures:
@@ -24,14 +24,6 @@ AssertionError: expected { value: 2, done: true } to deeply equal { value: 4, do
at test (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-async-generator-functions-test-fixtures-async-generators-await-in-finally-exec.test.js:28:44)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
./fixtures/babel/babel-plugin-transform-async-generator-functions-test-fixtures-yield-star-throw-method-sync-iterator-exec.test.js
AssertionError: expected [ Array(3) ] to deeply equal [ 'next', 'throw:TEST', …(1) ]
at ./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-async-generator-functions-test-fixtures-yield-star-throw-method-sync-iterator-exec.test.js:57:16
at Generator.next (<anonymous>)
at asyncGeneratorStep (./npm/runtime/src/helpers/asyncToGenerator.js:3:17)
at _next (./npm/runtime/src/helpers/asyncToGenerator.js:17:9)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
./fixtures/babel/babel-plugin-transform-async-to-generator-test-fixtures-async-to-generator-async-complex-params-exec.test.js
TypeError: Cannot destructure property 'b' of 'undefined' as it is undefined.
at Object.foo (./tasks/transform_conformance/fixtures/babel/babel-plugin-transform-async-to-generator-test-fixtures-async-to-generator-async-complex-params-exec.test.js:7:13)