Repository navigation
Description
🔎 Search Terms
getAsyncFromSyncIterationTypes, yield thenable, TS1321 crash, yield* Debug Failure
🕗 Version & Regression Information
Reproduces with the JavaScript checker in typescript@6.0.3 and the native checker in typescript@7.1.0-beta and typescript@7.1.0-dev.20261111.1, on Linux x64 using Node.js 24.20.0.
Also reproduces in an unmodified local build of current main, commit ad24728023c52ef6a92a278046cdb69621048365 (7.1.0-dev), built with node node_modules/hereby/bin/hereby.js build.
The first affected version has not been identified. I reviewed the FAQ and found no entry covering this crash.
💻 Code
Save as repro.ts:
declare const thenable: { then(onfulfilled: number): void };
async function* gen() {
yield* [thenable];
}npm install typescript@7.1.0-dev.20261111.1
npx tsc --noEmit --strict --target esnext repro.ts🙁 Actual behavior
The native checker panics while constructing a diagnostic:
panic: runtime error: invalid memory address or nil pointer dereference
.../internal/diagnostics.(*Message).Code
.../internal/checker.NewDiagnosticChainForNode
.../internal/checker.(*Checker).getAwaitedTypeNoAliasEx
.../internal/checker.(*Checker).getAwaitedTypeEx
.../internal/checker.(*Checker).getAsyncFromSyncIterationTypes
The local native build reproduces in both default mode and with --singleThreaded.
The JavaScript checker in 6.0.3 also crashes:
Error: Debug Failure.
at getAwaitedTypeNoAlias
at getAwaitedType
at getAsyncFromSyncIterationTypes
at getIterationTypesOfIterableWorker
🙂 Expected behavior
Report an ordinary diagnostic for the invalid thenable and complete checking without an internal error.
For comparison, replacing yield* [thenable] with yield thenable reports TS1321 without crashing on all three versions:
Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member.
Replacing the operand with yield* [1] succeeds.
Additional information about the issue
getAsyncFromSyncIterationTypes calls getAwaitedTypeEx with a non-nil error node but a nil diagnostic message. The invalid-thenable error path later attempts to construct a diagnostic using that message. In the JavaScript implementation the equivalent path asserts that the message is defined.
Source inspected at commit ad24728023c52ef6a92a278046cdb69621048365:
https://github.com/microsoft/TypeScript/blob/ad24728023c52ef6a92a278046cdb69621048365/tsc/internal/checker/checker.go#L6656-L6670
Related reports:
- Debug assert in getAwaitedTypeNoAlias in test262 repo #53145, fixed by Fix crash in getAwaitedType #54107, reached the same awaited-type assertion through a different iterator-checking path.
- Crash on async generator that yields a thenable and another value #65378 and its open PR fix(checker): avoid crashing on invalid async generator yields #65398 concern mixed direct yields and a missing type entering yield-type aggregation. This reproducer has a single delegated yield. The missing diagnostic in
getAsyncFromSyncIterationTypesis a separate path from the aggregation change in that PR.
Activity