Skip to content

Conversation

ahejlsberg
Copy link
Member

With this PR we only cache control flow type information in loop-back junction labels. Previously we'd cache in all junction labels, but that would sometimes prevent evolving types from being observed. For example:

let x: string | undefined;
while (true) {
    if (cond) {
        x = "";
    }
    else {
        if (x) {
            x.length;
        }
        if (x) {
            x.length;  // Would previously error here
        }
    }
}

Previously we'd error in the code above because we would have cached the type undefined for x in the junction label of following the preceding if statement.

@mhegazy
Copy link
Contributor

mhegazy commented Apr 25, 2016

👍

@ahejlsberg ahejlsberg merged commit dc60e68 into master Apr 25, 2016
@mhegazy mhegazy deleted the controlFlowCacheFix branch November 2, 2017 21:05
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants