ceylon / ceylon-js

DEPRECATED
Apache License 2.0
54 stars 9 forks source link

Flow typing on `else if` #531

Closed jvasileff closed 9 years ago

jvasileff commented 9 years ago

The following produces incorrect results at runtime:

    Float toFloat(Integer|Float x)
        =>  if (is Float x) then x
            else if (false) then x.float
            else x.float;

    print(toFloat(1)); // "<null>"

The same happens if false is replaced with true.

gavinking commented 9 years ago

Confirmed.

chochos commented 9 years ago

The problem is not really with flow typing but with the if expression.

jvasileff commented 9 years ago

Thanks, that was quick!