Rust: Infer certain types for logical operators

This commit is contained in:
Simon Friis Vindum
2025-08-27 13:19:49 +02:00
parent 0ff4dbcea0
commit 2f4e2d6d79

View File

@@ -383,6 +383,8 @@ private module CertainTypeInference {
result = inferRefNodeType(n) and
path.isEmpty()
or
result = inferLogicalOperationType(n, path)
or
result = inferTupleRootType(n) and
path.isEmpty()
or
@@ -440,11 +442,10 @@ private module CertainTypeInference {
}
private Type inferLogicalOperationType(AstNode n, TypePath path) {
exists(Builtins::BuiltinType t, BinaryLogicalOperation be |
exists(Builtins::Bool t, BinaryLogicalOperation be |
n = [be, be.getLhs(), be.getRhs()] and
path.isEmpty() and
result = TStruct(t) and
t instanceof Builtins::Bool
result = TStruct(t)
)
}
@@ -2381,8 +2382,6 @@ private module Cached {
(
result = inferAnnotatedType(n, path)
or
result = inferLogicalOperationType(n, path)
or
result = inferAssignmentOperationType(n, path)
or
result = inferTypeEquality(n, path)