Skip to content

Commit

Permalink
Fix #4516 - treat exit() as the empty type
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Nov 9, 2020
1 parent 683546e commit 3aaa1d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public static function analyze(
$context->inside_call = false;
}

$statements_analyzer->node_data->setType($stmt, \Psalm\Type::getEmpty());

return true;
}
}
17 changes: 17 additions & 0 deletions tests/MatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@ function foo(int $i) {
false,
'8.0',
],
'exitIsLikeThrow' => [
'<?php
/**
* @param 1|2|3 $i
*/
function foo(int $i): void {
$a = match ($i) {
1 => exit(),
2, 3 => $i,
};
$a === "aaa";
}',
'error_message' => 'DocblockTypeContradiction',
[],
false,
'8.0',
],
];
}
}

0 comments on commit 3aaa1d8

Please sign in to comment.