No typechecker error for undefined shape fields with inferred TAny value type
- Dominant language
- C++
- Stars
- 18.7k
- Forks
- 3.1k
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
**Describe the bug**
The typechecker should error when a shape has an undefined field. However, if the field has no inferred type type, there is no error.
**Standalone code, or other way to reproduce the problem**
```Hack
string) {
// When uncommented, this return produces the expected error:
// return shape('name' => 'A', 'color' => 'blue');
//
// --> shape_fields.php
// 7 | function shape_ret_example(): shape('name' => string) {
// | ^^^^^^^^^^^^^^^^^^^^^^^ Expected nothing because the field 'color' is not defined in this shape type, and this shape type does not allow unknown fields
// 8 | return shape('name' => 'A', 'color' => 'blue');
// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// | ^^^^^^ But got string
// this return produces no error
return shape('name' => 'A', 'color' => no_type());
}
```
Steps to reproduce the behavior:
1. `hh_client`
**Expected behavior**
hh_client reports a typechecker error, "Expected nothing because the field 'color' is not defined in this shape type, and this shape type does not allow unknown fields"
**Desktop (please complete the following information):**
- OS: MacOS Mojave
- HHVM Version: nightly at 2020-02-12
```
hhvm --version
HipHop VM 4.45.0-dev (rel)
Compiler: 1581479524_N
Repo schema: da39a3ee5e6b4b0d3255bfef95601890afd80709
```
```
hh_client --version
hackc-c370daa5736b2f9429d5737231d4aa611bdd9c7f-4.45.0-dev
```
Contributor guide
Assessment
This issue has not been assessed yet.