Skip to content

Propagate nonInferrableType in &&, || and ?? operators #38035

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
merged 3 commits into from
Apr 20, 2020
Merged

Conversation

ahejlsberg
Copy link
Member

Fixes #37974.

@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 18, 2020

Heya @ahejlsberg, I've started to run the extended test suite on this PR at ade45ee. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 18, 2020

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at ade45ee. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 18, 2020

Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at ade45ee. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@ahejlsberg
Copy link
Member Author

Tests all look clean (DT errors are preexisting conditions).

@weswigham
Copy link
Member

Do ternaries also need a fix at all? They union two branches, and a ? a : b scans a lot like a || b.

@ahejlsberg
Copy link
Member Author

Thought about it some more and realized the real issue here is that getTypeFacts should return TypeFacts.None for never. Right now it returns TypeFacts.All, similar to what we return for any and unknown, and that's definitely not right. Once we return TypeFacts.None there is no need to modify the logic for the operators because never then propagates naturally.

@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 18, 2020

Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at 96f45ff. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 18, 2020

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 96f45ff. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 18, 2020

Heya @ahejlsberg, I've started to run the extended test suite on this PR at 96f45ff. You can monitor the build here.

@andrewbranch
Copy link
Member

Thought about it some more and realized the real issue here is that getTypeFacts should return TypeFacts.None for never.

In one of my experiments, I actually tried doing this specifically for nonInferrableType instead of for all never. If I recall correctly, it caused a bunch of baseline errors, so I abandoned that approach. Nice to know I was on the right track after all.

@ahejlsberg ahejlsberg merged commit 5d78cbd into master Apr 20, 2020
@ahejlsberg ahejlsberg deleted the fix37974 branch April 20, 2020 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler crashes with generics
4 participants