@@ -324,13 +324,19 @@ private module CertainTypeInference {
324324 or
325325 // A `let` statement with a type annotation is a coercion site and hence
326326 // is not a certain type equality.
327- exists ( LetStmt let | not let .hasTypeRepr ( ) |
328- let .getPat ( ) = n1 and
327+ exists ( LetStmt let |
328+ not let .hasTypeRepr ( ) and
329+ // Due to "binding modes" the type of the pattern is not necessarily the
330+ // same as the type of the initializer. The pattern being an identifier
331+ // pattern is sufficient to ensure that this is not the case.
332+ let .getPat ( ) .( IdentPat ) = n1 and
329333 let .getInitializer ( ) = n2
330334 )
331335 or
332336 exists ( LetExpr let |
333- let .getPat ( ) = n1 and
337+ // Similarly as for let statements, we need to rule out binding modes
338+ // changing the type.
339+ let .getPat ( ) .( IdentPat ) = n1 and
334340 let .getScrutinee ( ) = n2
335341 )
336342 or
@@ -377,6 +383,11 @@ private module CertainTypeInference {
377383 result = inferRefNodeType ( n ) and
378384 path .isEmpty ( )
379385 or
386+ result = inferLogicalOperationType ( n , path )
387+ or
388+ result = inferRangeExprType ( n ) and
389+ path .isEmpty ( )
390+ or
380391 result = inferTupleRootType ( n ) and
381392 path .isEmpty ( )
382393 or
@@ -434,11 +445,10 @@ private module CertainTypeInference {
434445}
435446
436447private Type inferLogicalOperationType ( AstNode n , TypePath path ) {
437- exists ( Builtins:: BuiltinType t , BinaryLogicalOperation be |
448+ exists ( Builtins:: Bool t , BinaryLogicalOperation be |
438449 n = [ be , be .getLhs ( ) , be .getRhs ( ) ] and
439450 path .isEmpty ( ) and
440- result = TStruct ( t ) and
441- t instanceof Builtins:: Bool
451+ result = TStruct ( t )
442452 )
443453}
444454
@@ -456,6 +466,9 @@ private Struct getRangeType(RangeExpr re) {
456466 re instanceof RangeToExpr and
457467 result instanceof RangeToStruct
458468 or
469+ re instanceof RangeFullExpr and
470+ result instanceof RangeFullStruct
471+ or
459472 re instanceof RangeFromToExpr and
460473 result instanceof RangeStruct
461474 or
@@ -486,6 +499,11 @@ private predicate typeEquality(AstNode n1, TypePath prefix1, AstNode n2, TypePat
486499 or
487500 n1 = n2 .( MatchExpr ) .getAnArm ( ) .getExpr ( )
488501 or
502+ exists ( LetExpr let |
503+ n1 = let .getScrutinee ( ) and
504+ n2 = let .getPat ( )
505+ )
506+ or
489507 exists ( MatchExpr me |
490508 n1 = me .getScrutinee ( ) and
491509 n2 = me .getAnArm ( ) .getPat ( )
@@ -2370,8 +2388,6 @@ private module Cached {
23702388 (
23712389 result = inferAnnotatedType ( n , path )
23722390 or
2373- result = inferLogicalOperationType ( n , path )
2374- or
23752391 result = inferAssignmentOperationType ( n , path )
23762392 or
23772393 result = inferTypeEquality ( n , path )
@@ -2392,9 +2408,6 @@ private module Cached {
23922408 or
23932409 result = inferAwaitExprType ( n , path )
23942410 or
2395- result = inferRangeExprType ( n ) and
2396- path .isEmpty ( )
2397- or
23982411 result = inferIndexExprType ( n , path )
23992412 or
24002413 result = inferForLoopExprType ( n , path )
0 commit comments