diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index e5835423..c88c484a 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -4203,7 +4203,7 @@ class CompilerBase extends \PhpAot\Core\Translator implements PropertyAccessCont protected function parseIfChain(array $arms, ?Node\Stmt\Else_ $else, int $index): string { if (!isset($arms[$index])) { - if (!$else) { + if (!$else || (count($else->stmts) == 1 && $else->stmts[0] instanceof Node\Stmt\Nop)) { return ''; } return $this->parseBlockStmts($else->stmts); diff --git a/tests/core/basic/empty-else.phpt b/tests/core/basic/empty-else.phpt new file mode 100644 index 00000000..bc68bacb --- /dev/null +++ b/tests/core/basic/empty-else.phpt @@ -0,0 +1,19 @@ +--TEST-- +empty else +--FILE-- + +--EXPECT-- +success