Switches use binary search on a sorted array. Using floating point NaN
either as a case entry or as a lookup value therefore does not work
properly. I think the current situation can lead to bugs easily, e.g.
when using case ranges with floats as in this rather artificial example:

int is_in_range(float f) {
        switch (v) {
        case 0.0..1.0:
                return 1;
        default:
                return 0
        }
}

I think we should (1) issue a warning when Math.nan is used inside a
case and (2) make sure that switch (Math.nan) does not match any case.

Any comments?

arne

Reply via email to