hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Hack calls methods members

Open HRMsimon opened this issue 9 years ago • 5 comments

HHVM Version

f0f3a9e0002edd52415205a46a1e77d808f297df Tue Feb 28 09:10:12 2017

Standalone code, or other way to reproduce the problem

<?hh // strict

abstract class Foo {
  abstract public function baz(int $number): void;
}

final class Bar extends Foo {
  public function baz(): void {}
}

Expected result

An error about the method baz in Bar having the wrong number of arguments

Actual result

Hack calls baz a member instead.

test.php:7:13,15: Class Bar does not correctly implement all required methods  (Typing[4040])
  test.php:7:25,27: Some methods are incompatible with those declared in type Foo
Read the following to see why:
  test.php:8:19,21: Member baz has the wrong type
  test.php:8:19,21: Too few arguments
  test.php:4:28,30: Because of this definition

HRMsimon avatar Feb 27 '17 22:02 HRMsimon

Is this wrong? It correctly says "Too few arguments". And using the term member function isn't that much off either.

SiebelsTim avatar Feb 28 '17 08:02 SiebelsTim

Is the issue with the wording of Member baz has the wrong type vs Method baz has the wrong type? I think this is the intended wording.

mofarrell avatar Feb 28 '17 18:02 mofarrell

Yes, the problem is with the word Member. Member tends to refer to properties, not methods. PHP also calls functions inside a class methods, so there shouldn't be a reason for Hack to diverge in terminology.

HRMsimon avatar Mar 02 '17 21:03 HRMsimon

I think this is intentional. The term "member function" is a synonym for "method". The word "member" could refer to either member functions, or member variables. In this case it was referring to a member function.

mofarrell avatar Mar 03 '17 01:03 mofarrell

If you submit a PR I would try to get it by hack team members, but I don't see too much value in the change given the error is already pretty clear.

mofarrell avatar Mar 03 '17 01:03 mofarrell