facebook / facebook/hhvm

[Regression | Typechecker] Switch cases have become far less strict

Open
#8,544 4 comments 0 reactions 0 assignees View on GitHub
hack regression
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

### HHVM Version

HipHop VM 4.15.0 (rel)
Compiler: 1563823444_067594131
Repo schema: 55936598ef25c809003ec394e52b0d26b3121f31
hackc-78d2293bfefbe359ca775387521e434d0acea352-4.15.0

### Operating System and Version

Ubuntu 18.04

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

```HACK
enum Strings: string {
key = 'value';
}

<<__EntryPoint>>
function main(): noreturn {

switch ('a string') {
case Strings::key:
echo 'This is a typecheck time mismatch.';
}

switch (1) {
case Strings::key:
echo
'This is both a typecheck type mismatch and a runtime type mismatch.';
}

switch (1) {
case '1 string':
echo 'I would coerce at runtime';
}

exit();
}
```

### Actual result

hh_client `No errors!`

### Expected result

Complain about switch type mismatch.

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.