Merge pull request '修复 while do...while和if中的判断是赋值导致的C++编译警告的问题' (#3) from condition_assign into master

Reviewed-on: #3
pull/4/head
韩天峰 2 months ago
commit 036e2befc4
  1. 8
      src/Php/CompilerBase.php
  2. 12
      tests/aot/basic/condition-assign.phpt

@ -1437,6 +1437,10 @@ class CompilerBase extends \PhpAot\Core\Translator implements PropertyAccessCont
$this->appendCapturedStmtLines($code, $afterStmts);
$condExpr = $tmpVar;
}
if ($cond instanceof Expr\Assign) {
$condExpr = '(' . $condExpr . ')';
}
$code .= $openPrefix . '(' . $condExpr . ') {' . PHP_EOL;
return $code;
}
@ -4115,10 +4119,8 @@ class CompilerBase extends \PhpAot\Core\Translator implements PropertyAccessCont
if ($tail !== '') {
$code .= $this->getIndent() . '} else {' . PHP_EOL;
$code .= $tail;
$code .= $this->getIndent() . '}';
} else {
$code .= $this->getIndent() . '}';
}
$code .= $this->getIndent() . '}';
return $code;
};

@ -0,0 +1,12 @@
--TEST--
condition assign
--FILE--
<?php
function main() {
if ($value = true) {
echo "success";
}
}
?>
--EXPECT--
success
Loading…
Cancel
Save