Skip to content

Commit 0d432c6

Browse files
arnaud-lbCrell
authored andcommitted
AST: Update priorities for ZEND_AST_PIPE
Puts ZEND_AST_PIPE above comparison operators, and below math operators.
1 parent 82bae3c commit 0d432c6

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
@@ -2510,7 +2510,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
25102510
case ZEND_AST_GREATER_EQUAL: BINARY_OP(" >= ", 180, 181, 181);
25112511
case ZEND_AST_AND: BINARY_OP(" && ", 130, 130, 131);
25122512
case ZEND_AST_OR: BINARY_OP(" || ", 120, 120, 121);
2513-
case ZEND_AST_PIPE: BINARY_OP(" |> ", 130, 130, 131);
2513+
case ZEND_AST_PIPE: BINARY_OP(" |> ", 183, 183, 184);
25142514
case ZEND_AST_ARRAY_ELEM:
25152515
if (ast->child[1]) {
25162516
zend_ast_export_ex(str, ast->child[1], 80, indent);

0 commit comments

Comments
 (0)