Skip to content

Fix compiler crash on generics overload resolution failure - #62790

Closed
moznion (moznion) wants to merge 2 commits into
microsoft:mainfrom
moznion:fallback_error_message
Closed

Fix compiler crash on generics overload resolution failure#62790
moznion (moznion) wants to merge 2 commits into
microsoft:mainfrom
moznion:fallback_error_message

Conversation

@moznion

@moznion moznion (moznion) commented Nov 21, 2025

Copy link
Copy Markdown

Fixes #61524

Replace Debug.fail() calls with proper error generation to prevent TypeScript compiler crashes when overload resolution fails for complex generic constraints, for example JSX elements.

Problem

The TypeScript compiler crashes with "Debug Failure. No error for last overload signature" when resolving certain complex generic constraints, e.g., JSX element types. This regression has existed since TypeScript 3.6 and affects many React/JSX projects.

Root Cause

When getSignatureApplicabilityError() returns no diagnostics for overload candidates, the compiler calls Debug.fail() instead of handling the edge case gracefully, causing an immediate crash.

Solution

  • Replace Debug.fail() calls with fallback diagnostic generation
  • Generate appropriate error messages for unhandled overload resolution cases
  • Ensure compiler continues execution without crashing

Note

This change doesn’t fix the core logic of type inference. Ideally, that core should be fixed, but this pull request only addresses the compiler crash.

Related to #61524, #60229, #48636, #33133

Signed-off-by: moznion <moznion@mail.moznion.net>
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 21, 2025
@typescript-bot TypeScript Bot (typescript-bot) added the For Backlog Bug PRs that fix a backlog bug label Nov 21, 2025
@moznion moznion (moznion) changed the title Fix compiler crash on JSX overload resolution failure Fix compiler crash on generics overload resolution failure Nov 21, 2025
@moznion

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

…microsoft#61524

Replace `Debug.fail()` calls with proper error generation to prevent TypeScript
compiler crashes when overload resolution fails for complex generic constraints,
for example JSX elements.

Problem
--

The TypeScript compiler crashes with "Debug Failure. No error for last overload
signature" when resolving certain complex generic constraints, e.g., JSX element
types. This regression has existed since TypeScript 3.6 and affects many React/JSX
projects.

Root Cause
--

When `getSignatureApplicabilityError()` returns no diagnostics for overload
candidates, the compiler calls `Debug.fail()` instead of handling the edge case
gracefully, causing an immediate crash.

Solution
--

- Replace `Debug.fail()` calls with fallback diagnostic generation
- Generate appropriate error messages for unhandled overload resolution cases
- Ensure compiler continues execution without crashing

Related to microsoft#61524, microsoft#60229, microsoft#48636, microsoft#33133

Signed-off-by: moznion <moznion@mail.moznion.net>
@jakebailey

Copy link
Copy Markdown
Member

I think this is just papering over a bug somewhere else. IIRC the intent of these debug fails are to assert that the previous steps added an error.

@moznion

moznion (moznion) commented Dec 4, 2025

Copy link
Copy Markdown
Author

Jake Bailey (@jakebailey)
Thank you for your comment. Are you saying that the core issue lies in type inference, or somewhere else?
It makes sense from a language-processor perspective, but in our project the crash occurs during type checking, and it has been blocking us from upgrading from v5.6.3; this suggests the problem first appeared in v5.7.

@jakebailey

Copy link
Copy Markdown
Member

If it's a regression, I would consider bisecting with https://www.npmjs.com/package/every-ts

@moznion

moznion (moznion) commented Dec 4, 2025

Copy link
Copy Markdown
Author

I don't think this is a regression. It appears that the problem still occurs on the latest main branch.

@jakebailey

Copy link
Copy Markdown
Member

But you said it wasn't broken in 5.5, so there is a commit in between where this broke.

@jakebailey

Copy link
Copy Markdown
Member

But, #61524 (comment) seems to imply there's already a PR for this?

@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Mar 24, 2026
@typescript-bot

Copy link
Copy Markdown
Contributor

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

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: Done

Development

Successfully merging this pull request may close these issues.

Error: Debug Failure. No error for last overload signature

4 participants