Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HackC] class constant/enum shape keys are not namespace-aware #8195

Closed
fredemmott opened this issue May 10, 2018 · 1 comment
Closed

[HackC] class constant/enum shape keys are not namespace-aware #8195

fredemmott opened this issue May 10, 2018 · 1 comment

Comments

@fredemmott
Copy link
Contributor

HHVM Version

3.26.0

Operating System and Version

MacOS High Sierra

Standalone code, or other way to reproduce the problem

<?hh

namespace MyNS;

enum MyEnum: string {
  FOO = 'Herp';
}

type MyShape = shape(
  MyEnum::FOO => string,
);

type_structure(MyShape::class);

Expected result

No error (this is the case with HackC disabled)

Actual result

$ hhvm test.php

Fatal error: Uncaught Error: resolving type alias MyNS\MyShape failed. Have you declared all classes in the type alias in /private/tmp/hhtest/test.php:13
Stack trace:
#0 /private/tmp/hhtest/test.php(13): HH\type_structure()
#1 {main}

Extra: HHAS diff

$ hhvm -v Eval.DumpHhas=1 test.php > hackc.hhas
$ hhvm -v Eval.HackCompilerDefault=false -v Eval.DumpHhas=1 test.php > hphpc.hhas
$ diff -u hphpc.hhas hackc.hhas
--- hphpc.hhas	2018-05-10 11:58:39.000000000 -0700
+++ hackc.hhas	2018-05-10 11:58:29.000000000 -0700
@@ -7,13 +7,13 @@
 .hh_file 1;

 .main (1,1) {
-  .srcloc 5:1,5:1;
+  .srcloc 5:6,5:11;
   DefCls 0
-  .srcloc 9:1,11:2;
+  .srcloc 9:6,9:12;
   DefTypeAlias 0
   .srcloc 13:1,13:30;
   FPushFuncU 1 "HH\\type_structure" "type_structure"
-  .srcloc 13:16,13:29;
+  .srcloc 13:16,13:22;
   String "MyNS\\MyShape"
   .srcloc 13:1,13:30;
   FPassCE 0 Cell
@@ -29,5 +29,5 @@
   .const FOO = """s:4:\"Herp\";""";
 }

-.alias MyNS\MyShape = <"HH\\darray"  > """Y:2:{s:4:\"kind\";i:14;s:6:\"fields\";Y:1:{s:16:\"MyNS\\MyEnum::FOO\";Y:2:{s:10:\"is_cls_cns\";b:1;s:5:\"value\";Y:1:{s:4:\"kind\";i:4;}}}}""";
+.alias MyNS\MyShape = <"HH\\darray"  > """Y:2:{s:4:\"kind\";i:14;s:6:\"fields\";Y:1:{s:11:\"MyEnum::FOO\";Y:2:{s:10:\"is_cls_cns\";b:1;s:5:\"value\";Y:1:{s:4:\"kind\";i:4;}}}}""";
 # /private/tmp/hhtest/test.php ends here
@fredemmott
Copy link
Contributor Author

This blocks updating docs.hhvm.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant