From 8611f99e09107a45ff9848a0a71264e20f778caa Mon Sep 17 00:00:00 2001 From: Brown Date: Mon, 31 Aug 2020 23:23:24 -0400 Subject: [PATCH] Fix exhaustiveness checks for const value --- .../Statements/Expression/MatchAnalyzer.php | 6 +++-- tests/MatchTest.php | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php index 498e5159e..10cd07e88 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php @@ -143,15 +143,17 @@ class MatchAnalyzer throw new \UnexpectedValueException('bad'); } - $all_conds = array_merge($arm->conds, $all_conds); + $all_conds = \array_merge($arm->conds, $all_conds); } $all_match_condition = self::convertCondsToConditional( - array_values($all_conds), + \array_values($all_conds), $match_condition, $match_condition->getAttributes() ); + ExpressionAnalyzer::analyze($statements_analyzer, $all_match_condition, $context); + $clauses = \Psalm\Type\Algebra::getFormula( \spl_object_id($all_match_condition), \spl_object_id($all_match_condition), diff --git a/tests/MatchTest.php b/tests/MatchTest.php index 9d89e5472..a38fcdeeb 100644 --- a/tests/MatchTest.php +++ b/tests/MatchTest.php @@ -141,6 +141,28 @@ class MatchTest extends TestCase false, '8.0', ], + 'notAllConstEnumsMet' => [ + ' "John F Kennedy Airport", + self::LHR => "London Heathrow", + }; + } + }', + 'error_message' => 'UnhandledMatchCondition', + [], + false, + '8.0', + ], ]; } }