Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Zend/tests/gh18026.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
GH-18026: Confusing "amp" reference in parser error
--FILE--
<?php

class Demo {
private (set) mixed $v1;
}

?>
--EXPECTF--
Parse error: syntax error, unexpected token ")", expecting token "&" in %s on line %d
8 changes: 8 additions & 0 deletions Zend/zend_language_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,14 @@ static YYSIZE_T zend_yytnamerr(char *yyres, const char *yystr)
return sizeof("\"\\\"")-1;
}

/* We used "amp" as a dummy label to avoid a duplicate token literal warning. */
if (strcmp(toktype, "\"amp\"") == 0) {
if (yyres) {
yystpcpy(yyres, "token \"&\"");
}
return sizeof("token \"&\"")-1;
}

/* Strip off the outer quote marks */
if (toktype_len >= 2 && *toktype == '"') {
toktype++;
Expand Down
Loading