Fix "expecting token" error for ampersand
Currently, this is only handled for the "unexpected token" part of the message, but not the "expected" part. Fixes GH-18026 Closes GH-18101
This commit is contained in:
1
NEWS
1
NEWS
@ -37,6 +37,7 @@ PHP NEWS
|
||||
(ilutov)
|
||||
. Fixed bug GH-18033 (NULL-ptr dereference when using register_tick_function
|
||||
in destructor). (nielsdos)
|
||||
. Fixed bug GH-18026 (Improve "expecting token" error for ampersand). (ilutov)
|
||||
|
||||
- Curl:
|
||||
. Added curl_multi_get_handles(). (timwolla)
|
||||
|
12
Zend/tests/gh18026.phpt
Normal file
12
Zend/tests/gh18026.phpt
Normal file
@ -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
|
@ -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++;
|
||||
|
Reference in New Issue
Block a user