summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2014-12-07 22:58:14 +0100
committerNikita Popov <nikic@php.net>2014-12-07 23:00:48 +0100
commitc6d0c55a23918c8a5e8e2f583fc9ce58ddcd4e54 (patch)
treede6e4ba551f2bab20ffbeef532b02a8805adc521 /Zend
parentaa52fcf179d9e233075e4d213d5708cc5b5e1ae2 (diff)
downloadphp-git-c6d0c55a23918c8a5e8e2f583fc9ce58ddcd4e54.tar.gz
Fix arrow operator precedence
I accidentially added => as the highest-precedence operator...
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/generators/yield_precedence.phpt51
-rw-r--r--Zend/zend_language_parser.y2
2 files changed, 52 insertions, 1 deletions
diff --git a/Zend/tests/generators/yield_precedence.phpt b/Zend/tests/generators/yield_precedence.phpt
new file mode 100644
index 0000000000..6b87fa0364
--- /dev/null
+++ b/Zend/tests/generators/yield_precedence.phpt
@@ -0,0 +1,51 @@
+--TEST--
+Precedence of yield and arrow operators
+--FILE--
+<?php
+
+function gen() {
+ yield "a" . "b";
+ yield "a" or die;
+ yield "k" => "a" . "b";
+ yield "k" => "a" or die;
+ var_dump([yield "k" => "a" . "b"]);
+ yield yield "k1" => yield "k2" => "a" . "b";
+ yield yield "k1" => (yield "k2") => "a" . "b";
+ var_dump([yield "k1" => yield "k2" => "a" . "b"]);
+ var_dump([yield "k1" => (yield "k2") => "a" . "b"]);
+}
+
+$g = gen();
+for ($g->rewind(), $i = 1; $g->valid(); $g->send($i), $i++) {
+ echo "{$g->key()} => {$g->current()}\n";
+}
+
+?>
+--EXPECT--
+0 => ab
+1 => a
+k => ab
+k => a
+k => ab
+array(1) {
+ [0]=>
+ int(5)
+}
+k2 => ab
+k1 => 6
+2 => 7
+3 => k2
+k1 => 9
+10 => ab
+k2 => ab
+k1 => 12
+array(1) {
+ [0]=>
+ int(13)
+}
+11 => k2
+k1 => 14
+array(1) {
+ [15]=>
+ string(2) "ab"
+}
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 88286203da..94734defe2 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -70,6 +70,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%left T_LOGICAL_AND
%right T_PRINT
%right T_YIELD
+%right T_DOUBLE_ARROW
%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL T_POW_EQUAL
%left '?' ':'
%right T_COALESCE
@@ -93,7 +94,6 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%left T_ELSE
%left T_ENDIF
%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
-%right T_DOUBLE_ARROW
%token <ast> T_LNUMBER "integer number (T_LNUMBER)"
%token <ast> T_DNUMBER "floating-point number (T_DNUMBER)"