Closed
Description
Here is the working example: https://webassembly.studio/?f=zi21djvj57
Consider this example
function orNull(i: i32): Foo | null {
if (i % 2 == 0)
return null;
return new Foo();
}
function example(): Foo | null {
let x: Foo | null = orNull(1);
if (x == null){
return null;
}
return id(x); // x is not null, but compiler requires an explicit cast.
}
function id(f: Foo): Foo{
return f;
}
Not sure how big of a problem this is since it might be better to enforce being explicit, but I thought I'd share it. Also the same is true for if/else branches.