-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-dart2wasmIssues for the dart2wasm compiler.Issues for the dart2wasm compiler.area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.vm-tfa
Description
Follow up to: #59840
One of TFA's tree-shaker passes is normally able to remove null checks that are performed on non-nullable types. However, when assertions are enabled it is possible that the type of variable will get refined to a non-nullable type but a null checks on that local will not get cleared.
Example from other bug:
void main() {
repro(something: 1.0, other: 1.0);
}
void repro({double? something, double? other}) {
assert(
(something == null && other == null) ||
(something != null && other != null),
);
if (something != null) {
print(something);
print(other!); // Crash!
}
}
The type of repro#other is correctly refined to double (not nullable) since the only call site provides a non-null value. However, the assertion in the body of repro causes the non-null check, other!, to be retained. So we end up performing a non-null check on a value that has been inferred to be non-nullable. TFA should be able to check the inferred type and remove this check.
Metadata
Metadata
Assignees
Labels
area-dart2wasmIssues for the dart2wasm compiler.Issues for the dart2wasm compiler.area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.vm-tfa