facebook / facebook/hhvm

Hack: Allow this as a parameter to a callable in a static member variable

Open
#7,365 2 comments 0 reactions 0 assignees View on GitHub
hack
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

### HHVM Version

3.15.0
### Standalone code, or other way to reproduce the problem

``` hack
$callables = [];

public static function getCallables(): array<(function(this):void)> {
return static::$callables;
}
}
```
### Expected result

No errors!
### Actual result

```
The type "this" cannot be used as a constraint on a class' generic, or as the type of a static member variable (Naming[2043])
```

Contributor guide

Open the contributing guide

Research direction

Start with the standalone Hack reproduction and the Naming[2043] diagnostic shown in the issue. Trace the type-checking path for `this` in a static member variable and callable parameter; done means the example type-checks without errors and existing related checks remain valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.