- Notifications
You must be signed in to change notification settings - Fork 13k
someTypeRelatedToType now passes isIntersectionConstituent #33213
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
Merged
sandersn merged 3 commits into master from fix-missed-intersection-constituent-threading Sep 4, 2019
Merged
someTypeRelatedToType now passes isIntersectionConstituent #33213
sandersn merged 3 commits into master from fix-missed-intersection-constituent-threading Sep 4, 2019
Conversation
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
weswigham reviewed Sep 3, 2019
src/compiler/checker.ts Outdated
} | ||
else { | ||
const allDiagnostics: DiagnosticRelatedInformation[][] = []; | ||
const allDiagnostics: Array<ReadonlyArray<DiagnosticRelatedInformation>> = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
const allDiagnostics: Array<ReadonlyArray<DiagnosticRelatedInformation>> = []; | |
const allDiagnostics: (readonly DiagnosticRelatedInformation[])[] = []; |
to fix that lint failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our parsing for readonly T[][]
is so bad, and yet we have a lint rule requiring it.
weswigham approved these changes Sep 3, 2019
@typescript-bot cherry-pick this to release-3.6 |
typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Sep 4, 2019
weswigham added a commit to weswigham/TypeScript that referenced this pull request Sep 5, 2019
…icrosoft#33213)" This reverts commit 8ca36f3.
timsuchanek pushed a commit to timsuchanek/TypeScript that referenced this pull request Sep 11, 2019
…#33213) * someTypeRelatedToType now passes isIntersectionConstituent * Fix [][] lint
sandersn added a commit that referenced this pull request Oct 28, 2019
isIntersectionConstituent controls whether relation checking performs excess property and common property checks. It is possible to fail a relation check with excess property checks turned on, cache the result, and then skip a relation check with excess property checks that would have succeeded. #33133 provides an example of such a program. Fixes #33133 the right way, so I reverted the fix at #33213 Fixes #34762 (by reverting #33213) Fixes #33944 -- I added the test from #34646
sandersn added a commit that referenced this pull request Oct 29, 2019
* Add isIntersectionConstituent to relation key isIntersectionConstituent controls whether relation checking performs excess property and common property checks. It is possible to fail a relation check with excess property checks turned on, cache the result, and then skip a relation check with excess property checks that would have succeeded. #33133 provides an example of such a program. Fixes #33133 the right way, so I reverted the fix at #33213 Fixes #34762 (by reverting #33213) Fixes #33944 -- I added the test from #34646 * Update comments in test
typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Oct 29, 2019
Component commits: 2e0b451 Add isIntersectionConstituent to relation key isIntersectionConstituent controls whether relation checking performs excess property and common property checks. It is possible to fail a relation check with excess property checks turned on, cache the result, and then skip a relation check with excess property checks that would have succeeded. microsoft#33133 provides an example of such a program. Fixes microsoft#33133 the right way, so I reverted the fix at microsoft#33213 Fixes microsoft#34762 (by reverting microsoft#33213) Fixes microsoft#33944 -- I added the test from microsoft#34646 14d7a44 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key ea80362 Update comments in test 0764275 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key
sandersn pushed a commit that referenced this pull request Oct 29, 2019
Component commits: 2e0b451 Add isIntersectionConstituent to relation key isIntersectionConstituent controls whether relation checking performs excess property and common property checks. It is possible to fail a relation check with excess property checks turned on, cache the result, and then skip a relation check with excess property checks that would have succeeded. #33133 provides an example of such a program. Fixes #33133 the right way, so I reverted the fix at #33213 Fixes #34762 (by reverting #33213) Fixes #33944 -- I added the test from #34646 14d7a44 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key ea80362 Update comments in test 0764275 Merge branch 'master' into add-isIntersectionConstituent-to-relation-key
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.
The quick check for intersection sources doesn't pass isIntersectionConstituent, which incorrectly causes excess property checking to happen on intersection constituents.
In this example, the quick check happens when checking
g(CC)
, and incorrectly finds thatCP
is not assignable to{ children?: boolean }
even though the latter is part ofCP & { children?: boolean }
. The result is then cached, which breaks the assignability check on the next line:<CC {...(null as CP) }/>
.This is a 3.6 regression, but the example is so complex that I'm not sure how hard it is to reproduce.
Fixes #33133
Edit: Added commentary from the issue:
The basic problem is that the flag
isIntersectionConstituent
, which is used to exempt intersection constituents from common-property checks ("weak types"), isn't threaded through one particular intersection call in assignability checking. I missed it when threading that flag through more calls in 3.6 (#32582), and my new assertion in overload error reporting caught the mistake. It's quite likely that this assert would have fired a lot more before #32582.