HaxeFoundation / HaxeFoundation/haxe

Exhaustive check for multiple Null<T> types

Open
#9,288 1 comment 0 reactions 0 assignees View on GitHub
bug feature-pattern-matching
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

4.0.5

```haxe
import haxe.ds.Option;

class Main {

public static function main() {
var o:{ foo : Null>, bar : Null> } = null;


switch [o.foo, o.bar] {
case [Some(foo), Some(bar)]:
1;
case [None, _]:
2;
case [_, None]:
3;
}

}
}
```

gives `Unmatched patterns: Some` at `o.bar`

adding two more cases fixes it:

```haxe
case [_, null]: 4;
case [null, _]: 5;
```

Doesn't seem to be consistent with pattern matching on single value (no need `case null`):

```haxe
switch o.bar {
case Some(bar):
1;
case None:
2;
}
```

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.