Closed mraleph closed 1 year ago
A few random thoughts:
foo && false
into let t = foo in false
is only valid with sound null safety (without sound null safety foo
should be checked for null).@mraleph Do you have a real-world example where the lack of the constant propagation / folding in these cases causes suboptimal code and affects performance or code size?
Right now we have some support for propagating constant boolean values through the program:
false && ...
intofalse
)However these passes have some unpredictable short comings and can surprise developers:
f() => true; g() => f(); h() => f() && g()
g()
will be inferred to returntrue
buth()
will notfalse && ... => false
but does not attempt to rewrite... && false
intolet t = ... in false
.We should consider making these more predictable.
/cc @alexmarkov