[ty] support type aliases in binary compares (#20445)

## Summary

Add missing `Type::TypeAlias` clauses to `infer_binary_type_comparison`.

## Test Plan

Added mdtests that failed before.
This commit is contained in:
Carl Meyer 2025-09-17 00:33:26 -07:00 committed by GitHub
parent 681ad2fd92
commit c2fa449954
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View file

@ -7721,6 +7721,20 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
))
}
(Type::TypeAlias(alias), right) => Some(self.infer_binary_type_comparison(
alias.value_type(self.db()),
op,
right,
range,
)),
(left, Type::TypeAlias(alias)) => Some(self.infer_binary_type_comparison(
left,
op,
alias.value_type(self.db()),
range,
)),
(Type::IntLiteral(n), Type::IntLiteral(m)) => Some(match op {
ast::CmpOp::Eq => Ok(Type::BooleanLiteral(n == m)),
ast::CmpOp::NotEq => Ok(Type::BooleanLiteral(n != m)),