Fix namespace elaboration for default function parameters
commitd23d150d07af2eb007fa43ded4e1b045b4ed3602
authorThomas Jiang <thomasjiang@fb.com>
Tue, 29 Oct 2019 20:36:20 +0000 (29 13:36 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 29 Oct 2019 20:38:22 +0000 (29 13:38 -0700)
tree2063359f006d96ef9a9f84526ab2d1a7e91eab56
parent62fb204a8a68fd8d39639a3fb39abe3a16da5f9b
Fix namespace elaboration for default function parameters

Summary:
Namespace elaboration during codegen currently treats all ids in default parameters as constants. Fix codegen to properly resolve these names (as classes, functions, records, or constants).

Also fix codegen for constants to consistently qualify names. Previously, default parameters would not always use qualified constants. Example:
```
namespace TestNamespace {
  const TEST_CONST = 'c';
  class TestClass {
    public function test_method($g = TEST_CONST) {}
  }
}
```
Produced:
```
.class TestNamespace\TestClass {
  // Wrong: not qualified here.
  .method [public] <"" N  > test_method($g = DV1("""TEST_CONST""")) {
  L0:
    Null
    RetC
  DV1:
    // Correct: qualified here.
    CnsE "TestNamespace\\TEST_CONST"
    SetL $g
    PopC
    JmpNS L0
  }
}
```

Change will produce
```
.class TestNamespace\TestClass {
  // Wrong: not qualified here.
  .method [public] <"" N  > test_method($g = DV1("""\\TestNamespace\\TEST_CONST""")) {
  L0:
    Null
    RetC
  DV1:
    // Correct: qualified here.
    CnsE "TestNamespace\\TEST_CONST"
    SetL $g
    PopC
    JmpNS L0
  }
}
```

Reviewed By: Wilfred

Differential Revision: D18145728

fbshipit-source-id: a8566ccafec9b5661aaee703f3ef2b39521e17d0
hphp/hack/src/hhbc/hhbc_hhas.ml
hphp/test/slow/namespace/const_param.php.expect
hphp/test/slow/reflection/closure_namespace.php
hphp/test/slow/reflection/closure_namespace.php.expectf