hhvm / hhast

Mutable AST library for Hack with linting and code migrations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnusedVariable false positive in method signature

ianhoffman opened this issue · comments

This sample code:

<?hh

final class C {
	private int $x = 1;
	public function say(int $y = $this->x): void {
		echo $y;
	}
}

Produces this error:

Variable is unused
  Linter: Facebook\HHAST\UnusedVariableLinter
  Location: tests/test.php:5:30
  Code:
  >$this

It seems like the linter should not view $this as a variable, since we're just accessing the $x property.

I'm running HHVM 4.99 and using the latest version of HHAST as well.