facebook / facebook/hhvm

Use type Bar\{Bar} treated differently to use type Bar\Bar

Open
#9,335 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

**Describe the bug**
We see an unexpected error in the code below. Replacing `use type Bar\{Bar};` with `use type Bar\Bar;` is a workaround for this issue.

**Standalone code, or other way to reproduce the problem**

```hack
namespace Foo;

use namespace Bar;
use type Bar\{Bar};

final class FooBar extends Bar {
const Bar\my_type CONFIG = shape('a' => 'b');
}

namespace Bar;

abstract class Bar {
const my_type CONFIG = shape('a' => 'b');
}

type my_type = shape('a' => string);
```

Steps to reproduce the behavior:
Run `hh_client` on the above

**Expected behavior**

No errors

**Actual behavior**

```
File "/root/foo.hack", line 6, characters 28-30:
Some members in class `Foo\FooBar` are incompatible with those declared in type `Bar\Bar` (Typing[4348])
File "/root/foo.hack", line 13, characters 9-15:
Expected `shape('a' => string)`
File "/root/foo.hack", line 7, characters 10-20:
But got `Bar\Bar\my_type`
```

**Environment**
Docker nightly
```
HipHop VM 6.33.0-dev (rel) (non-lowptr)
Compiler: 1676345911_402707174
Repo schema: 960a4d092e2e8175b8f0a3b2caecffb7c980c672
```

**Additional context**

Narrowed down to this breaking diff: https://github.com/facebook/hhvm/compare/e71e870eecb9fa200e198726e73e5c2382eeaac7...21598ba02ad84b923253dd0bbd98a5d185fed107

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.