]> granicus.if.org Git - php/commitdiff
Fixed bug #72395 (list() regression)
authorXinchen Hui <laruence@gmail.com>
Mon, 13 Jun 2016 16:21:14 +0000 (09:21 -0700)
committerXinchen Hui <laruence@gmail.com>
Mon, 13 Jun 2016 16:21:14 +0000 (09:21 -0700)
NEWS
Zend/tests/bug72395.phpt [new file with mode: 0644]
Zend/zend_language_parser.y

diff --git a/NEWS b/NEWS
index e67720a5a8cf4baf9e13f2eb3389e72b9abec96e..88dac1ee0494248c62cd6a819e3f1d83cef3a79b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP                                                                        NEWS
 ?? ??? 2016, PHP 7.1.0alpha2
 
 - Core:
+  . Fixed bug #72395 (list() regression). (Laruence)
   . Fixed bug #72373 (TypeError after Generator function w/declared return type
     finishes). (Nikita)
 
diff --git a/Zend/tests/bug72395.phpt b/Zend/tests/bug72395.phpt
new file mode 100644 (file)
index 0000000..e89ecdd
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Bug #72395 (list() regression)
+--FILE--
+<?php
+list(,,$a,,$b,) = array(1, 2, 3, 4, 5, 6);
+var_dump($a, $b);
+?>
+--EXPECT--
+int(3)
+int(5)
index 44c5cfb12b506785ea7f27903dcb19b86086aaa8..c37bd7f20ced3a1b3a930aafeb63e52c1f11fbd1 100644 (file)
@@ -250,7 +250,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
 %type <ast> class_const_list class_const_decl name_list trait_adaptations method_body non_empty_for_exprs
 %type <ast> ctor_arguments alt_if_stmt_without_else trait_adaptation_list lexical_vars
 %type <ast> lexical_var_list encaps_list
-%type <ast> array_pair non_empty_array_pair_list array_pair_list
+%type <ast> array_pair non_empty_array_pair_list array_pair_list possible_array_pair
 %type <ast> isset_variable type return_type type_expr
 %type <ast> identifier
 
@@ -1183,21 +1183,19 @@ property_name:
 ;
 
 array_pair_list:
-               /* empty */ { $$ = zend_ast_create_list(0, ZEND_AST_ARRAY); }
-       |       non_empty_array_pair_list { /* allow single trailing comma */ zend_ast_list *list = zend_ast_get_list($$ = $1); if (list->child[list->children - 1] == NULL) { list->children--; } }
+       non_empty_array_pair_list { /* allow single trailing comma */ zend_ast_list *list = zend_ast_get_list($$ = $1); if (list->child[list->children - 1] == NULL) { list->children--; } }
+;
+
+possible_array_pair:
+               /* empty */ { $$ = NULL; }
+       |       array_pair  { $$ = $1; }
 ;
 
 non_empty_array_pair_list:
-               non_empty_array_pair_list ',' array_pair
+               non_empty_array_pair_list ',' possible_array_pair
                        { $$ = zend_ast_list_add($1, $3); }
-       |       array_pair
+       |       possible_array_pair
                        { $$ = zend_ast_create_list(1, ZEND_AST_ARRAY, $1); }
-       |       non_empty_array_pair_list ',' /* empty, for LHS array lists */
-                       { $$ = zend_ast_list_add($1, NULL); }
-       |       ','
-                       { $$ = zend_ast_create_list(1, ZEND_AST_ARRAY, NULL); }
-       |       ',' array_pair
-                       { $$ = zend_ast_create_list(2, ZEND_AST_ARRAY, NULL, $2); }
 ;
 
 array_pair: