]> khamidou — GitHub mirrors - arcanist.git/commit
Fix XHPAST to detect use of undeclared variables in `catch`
authorepriestley <git@epriestley.com>
Wed, 21 May 2014 19:23:51 +0000 (12:23 -0700)
committerepriestley <git@epriestley.com>
Wed, 21 May 2014 19:23:51 +0000 (12:23 -0700)
commitc999f3e6b5c7edef82761ed1db00d79683e2e37a
tree26fd9ba86b9fca2ea416798c50168bc07a58c7e1
parent8274ffa44dec6838ddbc97d93bc6a43e7d03ad0e
Fix XHPAST to detect use of undeclared variables in `catch`

Summary:
Currently, when code has a block like:

  } catch (Exception $ex) {

...we attempt to mark "$ex" as declared. However, we incorrectly mark every variable used anywhere in the block as declared. This means we'll never raise this warning in a `catch` block.

Instead //only// mark the caught exception as declared.

Test Plan: Added a failing unit test and made it pass.

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: lpriestley, epriestley

Differential Revision: https://secure.phabricator.com/D9239
src/lint/linter/ArcanistXHPASTLinter.php
src/lint/linter/__tests__/xhpast/undeclared-variables.lint-test