Repository navigation
Fix checker crash when sync iteration awaits an invalid thenable - #65459
Open
Josué Barros (joshbarros) wants to merge 2 commits into
Open
Josué Barros (joshbarros) wants to merge 2 commits into
Josué Barros (joshbarros) wants to merge 2 commits into
Conversation
getAsyncFromSyncIterationTypes asked for an awaited type with a nil diagnostic. Reporting an invalid thenable then dereferenced that message. yield* reports TS1322 and for-await reports TS1320.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the iteration-diagnostic changes and accompanying regression coverage.
No open issues 🎉
What changed in this PR
Fixes #65452 by making the native checker report diagnostics instead of crashing when asynchronous iteration encounters an invalid thenable from a synchronous iterable.
Changes:
- Passes iteration context into awaited-type checking to select the appropriate diagnostic for
yield*andfor await. - Adds regression coverage for invalid thenables and valid delegated yields.
- Records expected diagnostics, inferred types, symbols, and JavaScript output.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/yieldStarSyncIterableThenable.ts |
Adds invalid-thenable regressions and valid-yield checks. |
tsc/testdata/baselines/reference/compiler/yieldStarSyncIterableThenable.types |
Records expected inferred types. |
tsc/testdata/baselines/reference/compiler/yieldStarSyncIterableThenable.symbols |
Records expected symbol bindings. |
tsc/testdata/baselines/reference/compiler/yieldStarSyncIterableThenable.js |
Records expected JavaScript output. |
tsc/testdata/baselines/reference/compiler/yieldStarSyncIterableThenable.errors.txt |
Records TS1322, TS1321, and TS1320 diagnostics. |
tsc/internal/checker/checker.go |
Supplies context-specific diagnostics when awaiting iteration yield and return types. |
Review effort: Balanced
…rationTypes Review feedback: the comment was redundant or unclear. The diagnostic choice is already visible from the surrounding code.
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
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.
Fixes #65452
getAsyncFromSyncIterationTypespassed a nil diagnostic intogetAwaitedTypeEx. When a sync iterable's yield or return value is a thenable that is not a promise, the checker tried to build that diagnostic and crashed. The native compiler panics inMessage.Code. The JavaScript checker hitsDebug.assertIsDefinedon the same path.The diagnostic now names the construct that is waiting:
yield*of a sync iterable reports TS1322for awaitreports TS1320yieldstill reports TS1321yield* [1]andyield* [Promise.resolve(1)]still type-check.I ran
go test ./internal/testrunnerforyieldStarSyncIterableThenable, and the existingforAwait,yieldStar,crashInYieldStar, andasyncYieldStarcompiler tests. I did not run the fullherebysuite.Drafted with assistance from Grok. I reviewed the diff and ran those tests.