mirror of
https://github.com/php/php-src.git
synced 2025-01-24 04:33:39 +08:00
Fix short-circuting (bug #69825)
This commit is contained in:
parent
6084844fb5
commit
f263932f38
30
Zend/tests/bug69825.phpt
Normal file
30
Zend/tests/bug69825.phpt
Normal file
@ -0,0 +1,30 @@
|
||||
--TEST--
|
||||
Bug #69825 (Short-circuiting failure)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
print "AND\n";
|
||||
var_dump(0 && 1);
|
||||
var_dump(0 && 0);
|
||||
var_dump(1 && 0);
|
||||
var_dump(1 && 1);
|
||||
|
||||
print "OR\n";
|
||||
var_dump(0 || 1);
|
||||
var_dump(0 || 0);
|
||||
var_dump(1 || 0);
|
||||
var_dump(1 || 1);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
AND
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
OR
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
@ -5854,7 +5854,10 @@ void zend_compile_short_circuiting(znode *result, zend_ast *ast) /* {{{ */
|
||||
|
||||
zend_compile_expr(&right_node, right_ast);
|
||||
|
||||
if (right_node.op_type == IS_CONST) {
|
||||
if (right_node.op_type == IS_CONST && (
|
||||
(ast->kind == ZEND_AST_AND && !zend_is_true(&right_node.u.constant))
|
||||
|| (ast->kind == ZEND_AST_OR && zend_is_true(&right_node.u.constant))
|
||||
)) {
|
||||
result->op_type = IS_CONST;
|
||||
ZVAL_BOOL(&result->u.constant, zend_is_true(&right_node.u.constant));
|
||||
zval_ptr_dtor(&right_node.u.constant);
|
||||
|
Loading…
Reference in New Issue
Block a user