Skip to content

Fix checker crash when async iteration awaits an invalid thenable - #65561

Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
microsoft:mainfrom
zhengdaodeguL:fix/yield-star-invalid-thenable-65452
Open

刘亦达 (zhengdaodeguL) wants to merge 1 commit into
microsoft:mainfrom
zhengdaodeguL:fix/yield-star-invalid-thenable-65452

Conversation

@zhengdaodeguL

@zhengdaodeguL 刘亦达 (zhengdaodeguL) commented Nov 18, 2026 •

Copy link
Copy Markdown

Fixes #65452

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 (nil dereference in Message.Code). The use site is now carried through the conversion: TS1322 is reported for yield*, TS1320 for for-await, the diagnostic location is kept while probing union constituents, and the any fallback 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 in getUnionType after TS1321 was reported for a plain yield of the same thenable.

Added the regression test yieldStarSyncIterableInvalidThenable with accepted baselines.

This differs from the earlier closed #65459: that approach did not cover union iterables — the checker silently accepted yield* over number[] | 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 validate were not run locally and are left for CI.

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Checker crashes on yield* of a synchronous iterable containing an invalid thenable

2 participants