Repository navigation
Fix checker crash when async iteration awaits an invalid thenable - #65561
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Conversation
getAsyncFromSyncIterationTypes passed a nil diagnostic into getAwaitedTypeEx, so awaiting a sync iterable whose yield or return value is a thenable that is not a valid promise crashed the checker (native: nil dereference in Message.Code). Carry the use site through the conversion instead: report TS1322 for yield*, TS1320 for for-await, keep the diagnostic location while probing union constituents, and do not cache the any fallback after a failed conversion so a second use of the same iterable still errors. Also skip a nil yielded type when aggregating async-generator return types, which otherwise panicked in getUnionType after TS1321 was reported for a plain yield of the same thenable. Fixes microsoft#65452
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, so awaiting a sync iterable whose yield or return value is a thenable that is not a valid promise crashed the checker (nil dereference inMessage.Code). The use site is now carried through the conversion: TS1322 is reported foryield*, TS1320 forfor-await, the diagnostic location is kept while probing union constituents, and theanyfallback is not cached after a failed conversion so a second use of the same iterable still errors. A nil yielded type is also skipped when aggregating async-generator return types, which otherwise panicked ingetUnionTypeafter TS1321 was reported for a plainyieldof the same thenable.Added the regression test
yieldStarSyncIterableInvalidThenablewith accepted baselines.This differs from the earlier closed #65459: that approach did not cover union iterables — the checker silently accepted
yield*overnumber[] | Iterable<BadThenable>because the diagnostic location was discarded while probing union constituents — and it did not address the second nil-yield-type panic fixed here.Verified locally: the repro from the issue now reports only TS1322 instead of crashing, the valid control exits 0, and the related test subset passes (108 configurations, 20 skipped, 0 failures). The full test suite and
hereby validatewere not run locally and are left for CI.