Skip to content

Commit

Permalink
Fix improper XHPAST parsing of namespace grammar like "use x as priva…
Browse files Browse the repository at this point in the history
…te;"

Summary:
Depends on D21067. Ref T13492. Converting unit tests to be readable exposed this error in the grammar.

Normally, "grammar_rule" rules emit a standalone Node. In this case, the bottom-level grammar rule is a collection of trivial rules and the callers configure the Node. Wrap the bottom-level rule in a configuration rule so the node is configured correctly and consistently, in exactly one place.

Test Plan: Ran unit tests.

Maniphest Tasks: T13492

Differential Revision: https://secure.phabricator.com/D21068
  • Loading branch information
epriestley committed Apr 7, 2020
1 parent e03431d commit a1ee2ab
Show file tree
Hide file tree
Showing 4 changed files with 1,604 additions and 1,597 deletions.
2 changes: 1 addition & 1 deletion src/parser/xhpast/__tests__/data/php-traits.php.test
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pass
> " "
> as
> " "
* "<INVALID TYPE \"0\">"
* n_STRING
> protected
* n_EMPTY
> " "
Expand Down
2 changes: 1 addition & 1 deletion src/parser/xhpast/bin/PhutilXHPASTBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class PhutilXHPASTBinary extends Phobject {
* This is the version that would be obtained with an up-to-date XHPAST
* build. The //actual// XHPAST build version may vary.
*/
const EXPECTED_VERSION = '7.1.5';
const EXPECTED_VERSION = '7.1.6';

/**
* The XHPAST build version.
Expand Down
12 changes: 9 additions & 3 deletions support/xhpast/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ trait_modifiers:
}
| member_modifier {
$$ = NNEW(n_METHOD_MODIFIER_LIST);
$$->appendChild(NTYPE($1, n_STRING));
$$->appendChild($1);
}
;

Expand Down Expand Up @@ -1370,14 +1370,20 @@ method_modifiers:
non_empty_member_modifiers:
member_modifier {
$$ = NNEW(n_CLASS_MEMBER_MODIFIER_LIST);
$$->appendChild(NTYPE($1, n_STRING));
$$->appendChild($1);
}
| non_empty_member_modifiers member_modifier {
$$ = $1->appendChild(NTYPE($2, n_STRING));
$$ = $1->appendChild($2);
}
;

member_modifier:
basic_member_modifier {
$$ = NTYPE($1, n_STRING);
}
;

basic_member_modifier:
T_PUBLIC
| T_PROTECTED
| T_PRIVATE
Expand Down
Loading

0 comments on commit a1ee2ab

Please sign in to comment.