Unsound behaviour allowed with return static
- Dominant language
- C++
- Stars
- 18.7k
- Forks
- 3.1k
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
```hack
<<__ConsistentConstruct>>
abstract class C1 {
final public function __construct(private T $value) {}
public static function from(mixed $value): this {
return new static($value);
}
public function getValue() : T {
return $this->value;
}
}
final class C2 extends C1 {}
<<__EntryPoint>>
function main() : string {
return C2::from(10)->getValue();
}
```
**Expected behavior**
Some sort of typechecker error maybe?
**Actual behavior**
No error (but running this produces a `TypeError`)
**Environment**
hhvm 4.100
Would be very interested to know how this might be handled. Related issue here: https://github.com/vimeo/psalm/issues/5383
Contributor guide
Assessment
This issue has not been assessed yet.