-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler missing "deep" type errors - 4.5.5 regression #50670
Comments
@typescript-bot bisect good v4.4.4 bad v4.5.5 |
The change between v4.4.4 and v4.5.5 occurred at bf6d164. |
That seems highly unlikely, @typescript-bot |
Pretty sure I’ve yet to see the bot’s bisect find the correct commit. How ironic that the thing meant to find bugs is buggy. 🤣 |
The issue with the bisect was that the culprit commit was cherry-picked from main to release-4.5, and I only look at the timeline of commits going into main. I’m far from a git expert, but (warning: likely butchering terminology ahead) And FWIW, the bisect usually works, you just coincidentally only notice the ones that are particularly embarrassing 😛 |
Reading the description on #46599, it seems like this is expected behavior. |
@andrewbranch @RyanCavanaugh I get that the compiler might give up on extremely deep generated types (I'm not sure I followed that thread fully, or at least that I identified the part that said this is expected behaviour) but shouldn't it "give up" by erroring, rather than saying "everything's fine" which seems dangerous? |
It's actually quite common to hit the depth limiter in sound code that can't be written any other way. |
@RyanCavanaugh but what about incorrect code that reaches the depth limit? I would suggest changing the default behavior of depth-limiting to be an error (if it's necessary to resolve to something, it could resolve to |
We tried that, of course. The places where it's practical (from a user perspective) to error already do error, such as These types of things are very common in unsuspicious code that doesn't appear to have any circularities, e.g. function f3<T>(x: Partial<T>[keyof T], y: NonNullable<Partial<T>[keyof T]>) {
x = y; If someone wants to send a PR for something that only errors in suspicious circumstances without incurring a big perf hit, we're welcome to it, but right now this is all one code path and we can't "fix" the OP without breaking the above snippet.
Issue an error where, though? The "starting point" for the instigating line of code for of a depth limiter hit that starts with a type comparison is effectively nondeterministic. |
Bug Report
When dealing with a fairly large type produced by a generic, differences in types can lead to what should be compile-time errors being ignored. Example (see last
// @ts-expect-error
).🔎 Search Terms
A hard thing to search for, but I tried "deep" and "false negative" and didn't see anything.
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
The compiler failed to noticed the difference between
void
andstring
, when it's sufficiently "deep" in the expanded object.🙂 Expected behavior
The compiler should have an error on the last line of the snippet.
The text was updated successfully, but these errors were encountered: