assemblyscript
assemblyscript copied to clipboard
`&&` and `||` expression will not change the `NONNULL` flag
This code should not pass the compile.
export function _start(): void {
let value: A | null = new A();
if (value != null) {
// value = null; // cause compile error correctly
true && (value = null); // compile passed, but value is changed to zero now
let a1 = value.a1;
}
}
Looking at this briefly, the cause here seems to be in the && respectively || cases in Compiler#compileBinaryExpression, where the state of rightFlow is not inherited by the parent flow, so its mutations are lost.
This issue will be addressed as part of #2578 (not yet merged) alongside a broader refactoring of the relevant flow logic solving similar issues in other places.