Skip to content
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

support flow-typing improvement #2333

Closed
gavinking opened this issue Oct 4, 2015 · 5 comments
Closed

support flow-typing improvement #2333

gavinking opened this issue Oct 4, 2015 · 5 comments
Assignees
Milestone

Comments

@gavinking
Copy link
Member

The backend needs to support the improvement in ceylon/ceylon-spec/issues/891.

An example is:

Integer fun(Integer? int) {
    if (!exists int) {
        return 0;
    }
    return int+1;
}

Which currently results in this backend error:

Bad operand types for binary operator +
  first type:  ceylon.language.Integer
  second type: long
@gavinking gavinking added this to the 1.2 milestone Oct 4, 2015
@quintesse
Copy link
Member

Could you give a small explanation of how you implemented it? Because I intuitively understood the SyntheticAssert but you removed and improved it and now it's not as obvious to me how to implement it on the backend.

@gavinking
Copy link
Member Author

I used the same strategy I use for narrowing in else clauses. I add a Variable. In this case the Variable gets slotted into block just after the if statement, and it gets a special new scope.

@FroMage
Copy link
Member

FroMage commented Oct 5, 2015

OK I'll bite.

@FroMage
Copy link
Member

FroMage commented Oct 5, 2015

Done!

@gavinking
Copy link
Member Author

Excellent, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants