Merge pull request #20 from AlessioGiacobbe/fix/unary-minus-parens
fix(parser): parenthesize unary minus operand to avoid C++ pre-decrement pastingmaster
commit
589f1494d4
2 changed files with 43 additions and 0 deletions
@ -0,0 +1,35 @@ |
||||
--TEST-- |
||||
Nested unary minus must not emit the C++ pre-decrement token |
||||
--FILE-- |
||||
<?php |
||||
|
||||
function negNative(int $x): int |
||||
{ |
||||
return - -$x; |
||||
} |
||||
|
||||
function main(): void |
||||
{ |
||||
$a = 5; |
||||
$b = - -$a; |
||||
echo $b, "\n"; |
||||
echo $a, "\n"; |
||||
|
||||
$c = -(-7); |
||||
echo $c, "\n"; |
||||
|
||||
$f = 1.5; |
||||
$g = - -$f; |
||||
echo $g, "\n"; |
||||
|
||||
echo negNative(9), "\n"; |
||||
echo - -(-3), "\n"; |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
5 |
||||
5 |
||||
7 |
||||
1.5 |
||||
9 |
||||
-3 |
||||
Loading…
Reference in new issue