facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.19k stars 3k forks source link

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

Open muglug opened 1 year ago

muglug commented 1 year ago

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

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

forms2772 commented 3 weeks ago

give chroma

forms2772 commented 3 weeks ago

in blooket