Acknowledged

SDK 8.0.0 beta: issue with conditionals from 7.4.1 is still present

There's a problem in early SDK 7.4.* versions (that have been pulled back) and in SDK 8.0.0 beta with enabled strict type checking:

import Toybox.Lang;

function f(x as Number) as Number? {
    // Object of type 'PolyType<Any or $.Toybox.Lang.Number>' does not match return type 'PolyType<Null or $.Toybox.Lang.Number>'.
    return x != null ? x : null;
}

Such code builds without errors in 7.3.1 and 7.4.3.

Parents
  • And even if the code was incorrect (due to comparing a non-nullable type to null), that wouldn't explain/excuse the behaviour reported in OP (that the type of the return value is subsequently assumed to be Any or Number.)

Comment
  • And even if the code was incorrect (due to comparing a non-nullable type to null), that wouldn't explain/excuse the behaviour reported in OP (that the type of the return value is subsequently assumed to be Any or Number.)

Children
No Data