Skip to content

Commit ed80a7e

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Unary minus const expression consistency
2 parents 960f071 + 41bbb11 commit ed80a7e

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Diff for: NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.2.6
44

5+
- Core:
6+
. Fix inconsistent float negation in constant expressions. (ilutov)
7+
58
- DOM:
69
. Fixed bug #80602 (Segfault when using DOMChildNode::before()).
710
(Nathan Freeman)

Diff for: Zend/tests/unary_minus_const_expr_consistency.phpt

+16
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)

Diff for: Zend/zend_ast.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,8 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_ex(zval *result, zend_ast *as
676676
if (UNEXPECTED(zend_ast_evaluate(&op2, ast->child[0], scope) != SUCCESS)) {
677677
ret = FAILURE;
678678
} else {
679-
ZVAL_LONG(&op1, 0);
680-
ret = sub_function(result, &op1, &op2);
679+
ZVAL_LONG(&op1, -1);
680+
ret = mul_function(result, &op1, &op2);
681681
zval_ptr_dtor_nogc(&op2);
682682
}
683683
break;

0 commit comments

Comments
 (0)