Avoid default action for error production

error is not necessarily going to have a semantic value, make sure
that the default action $$=$1 is not used.

Fixes #551.
This commit is contained in:
Nikita Popov 2018-11-30 11:00:48 +01:00
parent ebf6b1c33b
commit f42bbc2403
3 changed files with 9 additions and 2 deletions

View File

@ -959,6 +959,7 @@ array_pair_list:
comma_or_error:
','
| error
{ /* do nothing -- prevent default action of $$=$1. See #551. */ }
;
inner_array_pair_list:

View File

@ -2361,7 +2361,7 @@ class Php7 extends \PhpParser\ParserAbstract
$this->semValue = $this->semStack[$stackPos];
},
498 => function ($stackPos) {
$this->semValue = $this->semStack[$stackPos];
/* do nothing -- prevent default action of $$=$this->semStack[$1]. See $551. */
},
499 => function ($stackPos) {
$this->semStack[$stackPos-(3-1)][] = $this->semStack[$stackPos-(3-3)]; $this->semValue = $this->semStack[$stackPos-(3-1)];

View File

@ -1400,4 +1400,10 @@ array(
)
)
)
)
)
-----
<?php
$a = ["a "thing"];
-----
!!php7
Syntax error, unexpected T_STRING, expecting ',' or ')' or ']' from 2:11 to 2:15