Skip to content

Commit 4a4b4f6

Browse files
committed
Comment and reorder the parser hack
Still need to fix parse error message generation
1 parent 111e3c2 commit 4a4b4f6

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Zend/tests/type_declarations/intersection_types/invalid_types/invalid_nullable_type.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ function foo(): ?Countable&Iterator {}
77

88
?>
99
--EXPECTF--
10-
Parse error: syntax error, unexpected token "&", expecting "{" in %s on line %d
10+
Parse error: syntax error, unexpected token "&'", expecting "{" in %s on line %d

Zend/zend_language_parser.y

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,11 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
231231
%token T_COALESCE "'??'"
232232
%token T_POW "'**'"
233233
%token T_POW_EQUAL "'**='"
234-
%token T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG "'&'"
235-
%token T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG "'&''"
234+
/* We need to split the & token in two because otherwise Bison somehow lands
235+
* in a shift/reduce conflict for parameter intersection types */
236+
%token T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG "'&'"
237+
// TODO Fix parse error message
238+
%token T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG "'&''"
236239
%token T_BAD_CHARACTER "invalid character"
237240

238241
/* Token used to force a parse error from the lexer */

ext/tokenizer/tokenizer_data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ void tokenizer_register_constants(INIT_FUNC_ARGS) {
167167
REGISTER_LONG_CONSTANT("T_COALESCE", T_COALESCE, CONST_CS | CONST_PERSISTENT);
168168
REGISTER_LONG_CONSTANT("T_POW", T_POW, CONST_CS | CONST_PERSISTENT);
169169
REGISTER_LONG_CONSTANT("T_POW_EQUAL", T_POW_EQUAL, CONST_CS | CONST_PERSISTENT);
170-
REGISTER_LONG_CONSTANT("T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG", T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG, CONST_CS | CONST_PERSISTENT);
171170
REGISTER_LONG_CONSTANT("T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG", T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG, CONST_CS | CONST_PERSISTENT);
171+
REGISTER_LONG_CONSTANT("T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG", T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG, CONST_CS | CONST_PERSISTENT);
172172
REGISTER_LONG_CONSTANT("T_BAD_CHARACTER", T_BAD_CHARACTER, CONST_CS | CONST_PERSISTENT);
173173
REGISTER_LONG_CONSTANT("T_DOUBLE_COLON", T_PAAMAYIM_NEKUDOTAYIM, CONST_CS | CONST_PERSISTENT);
174174
}
@@ -319,8 +319,8 @@ char *get_token_type_name(int token_type)
319319
case T_COALESCE: return "T_COALESCE";
320320
case T_POW: return "T_POW";
321321
case T_POW_EQUAL: return "T_POW_EQUAL";
322-
case T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG: return "T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG";
323322
case T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG: return "T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG";
323+
case T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG: return "T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG";
324324
case T_BAD_CHARACTER: return "T_BAD_CHARACTER";
325325

326326
}

0 commit comments

Comments
 (0)