comparison of non null types to null are now errors

This commit is contained in:
Jakub Doka 2024-11-03 21:31:46 +01:00
parent 44fc9c3e2e
commit 61250c906a
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143

View file

@ -2704,7 +2704,11 @@ impl<'a> Codegen<'a> {
self.strip_var(&mut cmped);
let Some(ty) = self.tys.inner_of(cmped.ty) else {
return Some(self.ci.nodes.new_const_lit(ty::Id::BOOL, 1));
self.report(
left.pos(),
fa!("'{}' is never null, remove this check", self.ty_display(cmped.ty)),
);
return Value::NEVER;
};
Some(Value::new(self.gen_null_check(cmped, ty, op)).ty(ty::BOOL))