Skip to content

Remove ordering restrictions in control flow analysis #37134

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 4 commits into from
Feb 29, 2020
Merged

Conversation

ahejlsberg
Copy link
Member

In #36114 we removed ordering restrictions related to discriminant checks in control flow analysis. With this PR we remove all such remaining restrictions, specifically those related to instanceof, typeof, and user defined type predicate checks.

A bit of history... In #10028 we introduced logic that would reset control flow analysis types following discriminant and instanceof checks. For example, following obj instanceof Foo we'd reset all control flow types for properties of obj, effectively forgetting about any narrowing operations that occurred before the instanceof check. This resetting logic was needed to work around issues related to control flow analysis in loops, but wasn't otherwise justified. In fact, the motivating examples all worked just fine outside of loops. It wasn't until #35332 that we finally fixed the underlying issue (for other reasons), and there is no reason to have these restrictions anymore.

Fixes #36709.

@ahejlsberg ahejlsberg merged commit a5796cf into master Feb 29, 2020
@ahejlsberg ahejlsberg deleted the fix36709 branch February 29, 2020 20:03
@Lagily
Copy link

Lagily commented Mar 28, 2020

Does this also fix #37658?

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.

Type narrowing (null check) doesn't work if before instanceof
3 participants