Skip to content

Commit cbf3fbe

Browse files
committed
fix(codex): treat void as falsy
closes #789 Signed-off-by: azjezz <[email protected]>
1 parent 95ef9dd commit cbf3fbe

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
function returns_void(): void
6+
{
7+
}
8+
9+
if (returns_void()) { // @mago-expect analysis:impossible-condition
10+
echo 1;
11+
}

crates/analyzer/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ test_case!(issue_766);
506506
test_case!(issue_776);
507507
test_case!(issue_782);
508508
test_case!(issue_785);
509+
test_case!(issue_789);
509510

510511
#[test]
511512
fn test_all_test_cases_are_ran() {

crates/codex/src/ttype/atomic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ impl TAtomic {
713713
TAtomic::Scalar(scalar) if scalar.is_falsy() => true,
714714
TAtomic::Array(array) if array.is_falsy() => true,
715715
TAtomic::Mixed(mixed) if mixed.is_falsy() => true,
716-
TAtomic::Null => true,
716+
TAtomic::Null | TAtomic::Void => true,
717717
_ => false,
718718
}
719719
}

0 commit comments

Comments
 (0)