Skip to content

Commit ba33bbe

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Unary minus const expression consistency
2 parents 7359a45 + ed80a7e commit ba33bbe

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Unary minus constant expression consistency
3+
--FILE--
4+
<?php
5+
6+
const ZERO = 0.0;
7+
const MINUS_ZERO = -ZERO;
8+
$minus_zero = -ZERO;
9+
10+
var_dump(MINUS_ZERO);
11+
var_dump($minus_zero);
12+
13+
?>
14+
--EXPECT--
15+
float(-0)
16+
float(-0)

Zend/zend_ast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
712712
if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)) {
713713
ret = FAILURE;
714714
} else {
715-
ZVAL_LONG(&op1, 0);
716-
ret = sub_function(result, &op1, &op2);
715+
ZVAL_LONG(&op1, -1);
716+
ret = mul_function(result, &op1, &op2);
717717
zval_ptr_dtor_nogc(&op2);
718718
}
719719
break;

0 commit comments

Comments
 (0)