From 0eda76b7423a847c4c33efe8e6f3081a31aebf32 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Mon, 7 May 2018 18:09:40 -0400 Subject: [PATCH] Fix strict reconciliation of bools --- src/Psalm/Type/Reconciler.php | 4 +++- tests/TypeAlgebraTest.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 628b81fd2..b28efb22e 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -863,7 +863,9 @@ class Reconciler $did_remove_type = false; foreach ($existing_var_atomic_types as $type) { - if (!$type instanceof TBool) { + if (!$type instanceof TBool + || ($is_strict_equality && get_class($type) === TBool::class) + ) { $non_bool_types[] = $type; } else { $did_remove_type = true; diff --git a/tests/TypeAlgebraTest.php b/tests/TypeAlgebraTest.php index 83f3d7861..70bc80e8a 100644 --- a/tests/TypeAlgebraTest.php +++ b/tests/TypeAlgebraTest.php @@ -819,6 +819,18 @@ class TypeAlgebraTest extends TestCase $a = (($s === "a" && rand(0, 1)) || ($s === "b" && rand(0, 1))) ? 1 : 0;', ], + 'boolComparison' => [ + '