HaxeFoundation / HaxeFoundation/haxe
Guard messes up exhaustiveness check.
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
The following [produces](https://try.haxe.org/#dfC1F) `Unmatched patterns: Success`:
```haxe
using tink.CoreApi;
class Test {
static function main() {
switch Success({ success: true }) {
case Success(obj) if (obj.success): trace('yes!');
case Success(obj) if (!obj.success): trace('no!');
case Failure(_): trace('no!');
};
}
}
```
That's fair enough, because guards can be arbitrarily complex.
Consequently, the following should be considered non-exhaustive for the same reasons, but [it compiles just fine](https://try.haxe.org/#64b65) even though it doesn't match:
```haxe
using tink.CoreApi;
class Test {
static function main() {
switch Success({ success: true }) {
case Success({ success: false }): trace('no!');
case Success(obj) if (!obj.success): trace('no!');
case Failure(_): trace('no!');
};
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.