Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parser expectation error for amp token #18101

Closed
wants to merge 1 commit into from
Closed
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
@@ -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++;