Skip to content

Commit 5700cb2

Browse files
committed
AST: Update priorities for ZEND_AST_PIPE
Puts ZEND_AST_PIPE above comparison operators, and below math operators.
1 parent 2beea97 commit 5700cb2

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Zend/tests/pipe_operator/ast.phpt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ try {
7777
}
7878

7979
try {
80-
// Currently wrong
8180
assert(false && (foo() < bar()) |> baz());
8281
} catch (AssertionError $e) {
8382
echo $e->getMessage(), PHP_EOL;
@@ -90,15 +89,15 @@ try {
9089
}
9190

9291
?>
93-
--EXPECTF--
92+
--EXPECT--
9493
Concat, which binds higher
95-
assert(false && (foo() . bar() |> baz() . quux()))
96-
assert(false && (foo() . bar() |> baz() . quux()))
94+
assert(false && foo() . bar() |> baz() . quux())
95+
assert(false && foo() . bar() |> baz() . quux())
9796
assert(false && foo() . (bar() |> baz()) . quux())
98-
assert(false && (foo() . bar() |> baz() . quux()))
97+
assert(false && foo() . bar() |> baz() . quux())
9998
assert(false && (foo() . bar() |> baz()) . quux())
10099
assert(false && foo() . (bar() |> baz() . quux()))
101100
<, which binds lower
102101
assert(false && foo() < bar() |> baz())
103102
assert(false && (foo() < bar()) |> baz())
104-
assert(false && foo() < (bar() |> baz()))
103+
assert(false && foo() < bar() |> baz())

Zend/zend_ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
22962296
case ZEND_AST_GREATER_EQUAL: BINARY_OP(" >= ", 180, 181, 181);
22972297
case ZEND_AST_AND: BINARY_OP(" && ", 130, 130, 131);
22982298
case ZEND_AST_OR: BINARY_OP(" || ", 120, 120, 121);
2299-
case ZEND_AST_PIPE: BINARY_OP(" |> ", 130, 130, 131);
2299+
case ZEND_AST_PIPE: BINARY_OP(" |> ", 183, 183, 184);
23002300
case ZEND_AST_ARRAY_ELEM:
23012301
if (ast->child[1]) {
23022302
zend_ast_export_ex(str, ast->child[1], 80, indent);

0 commit comments

Comments
 (0)