1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Don't record anonymous functions into the symbol map

Summary:
Although we currently forbid anonymous functions, some day we will likely permit them, and our behavior for them is wrong.

Handle them correctly rather than throwing an exception because we should be covered by D1846 against accidental use, and we won't be on PHP 5.2 forever.

Test Plan: Ran against a test file with anonymous functions. Before, it emitted a declaration of a nameless function; afterward, it did not.

Reviewers: btrahan, edward

Reviewed By: btrahan

CC: aran, epriestley

Maniphest Tasks: T963

Differential Revision: https://secure.phabricator.com/D1847
This commit is contained in:
epriestley 2012-03-09 15:45:47 -08:00
parent 36709ece41
commit 6a7b1a7bdd

View file

@ -219,9 +219,14 @@ foreach (Futures($futures) as $file => $future) {
$functions = $root->selectDescendantsOfType('n_FUNCTION_DECLARATION'); $functions = $root->selectDescendantsOfType('n_FUNCTION_DECLARATION');
foreach ($functions as $function) { foreach ($functions as $function) {
$name = $function->getChildByIndex(2); $name = $function->getChildByIndex(2);
$requirements->addFunctionDeclaration( if ($name->getTypeName() == 'n_EMPTY') {
$name, // This is an anonymous function; don't record it into the symbol
$name->getConcreteString()); // index.
} else {
$requirements->addFunctionDeclaration(
$name,
$name->getConcreteString());
}
} }