Uh oh!
There was an error while loading. Please reload this page.
Stricter criteria for eliminating types in unions during inference - #32919
Conversation
Anders Hejlsberg (ahejlsberg)
commented
Aug 15, 2019
This PR slightly tweaks the conditions under which we eliminate types in unions during type inference. Specifically, it modifies the last bullet relating to union types in #32558 to be:
|
Anders Hejlsberg (ahejlsberg)
commented
Aug 15, 2019
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 6d46850. You can monitor the build here. It should now contribute to this PR's status checks. |
Anders Hejlsberg (ahejlsberg)
commented
Aug 15, 2019
DT run is clean, I think this one is ready to merge. |
Ryan Cavanaugh (RyanCavanaugh)
commented
Aug 15, 2019
Anders Hejlsberg (@ahejlsberg) did you specifically want this one in 3.6.1? |
| if (symbol) { | ||
| if (contains(symbolStack, symbol)) { | ||
| inferenceIncomplete = true; | ||
| inferencePriority = -1; |
There was a problem hiding this comment.
I can't tell if -1 is being used here because it's lower than anything else, has all bits set, or both. A named enum member with the intended semantics of this would be clearer.
There was a problem hiding this comment.
It's because -1 is less than any normal priority value. I'll give it a symbolic name.
| if (inferenceMatch) matched[i] = true; | ||
| inferenceMatch = inferenceMatch || saveInferenceMatch; | ||
| if (inferencePriority === priority) matched[i] = true; | ||
| inferenceCircularity = inferenceCircularity || inferencePriority < 0; |
There was a problem hiding this comment.
Is it possible for inferencePriority to be a negative value that isn't -1 ?
| const saveInferenceIncomplete = inferenceIncomplete; | ||
| inferenceMatch = false; | ||
| inferenceIncomplete = false; | ||
| (visited || (visited = createMap<number>())).set(key, -1); |
There was a problem hiding this comment.
Is the -1 here (used as number) the same -1 lower in the file?
Anders Hejlsberg (ahejlsberg)
commented
Aug 16, 2019
I think it is a very safe fix, so yes if possible. |
Ryan Cavanaugh (RyanCavanaugh)
commented
Aug 16, 2019
TypeScript Bot (@typescript-bot) cherry-pick this into release-3.6 |
TypeScript Bot (typescript-bot)
commented
Aug 16, 2019
Hey Ryan Cavanaugh (@RyanCavanaugh), I've opened #32933 for you. |
Component commits: a81ce06 Stricter criteria for eliminating types in unions during inference f929a25 Add regression test 6d46850 Accept new baselines 86d9153 Accept new API baselines abc61a0 Add InferencePriority.Circularity per CR feedback ac2f151 Accept new API baselines c816cf2 Add additional test af7ccf9 Accept new baselines
Component commits: a81ce06 Stricter criteria for eliminating types in unions during inference f929a25 Add regression test 6d46850 Accept new baselines 86d9153 Accept new API baselines abc61a0 Add InferencePriority.Circularity per CR feedback ac2f151 Accept new API baselines c816cf2 Add additional test af7ccf9 Accept new baselines
Fixes#32752.