HaxeFoundation / HaxeFoundation/haxe

Runtime error in exhaustive switch

Open
#7,215 16 comments 0 reactions 1 assignee Claimed by @Simn View on GitHub
platform-cpp platform-hl platform-jvm
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

The following code doesn't work well in HL because the switch is not exhaustive at runtime:

```haxe
enum abstract A(String) {
var A;
var B;
}

class Test {
static function foo( e : A ) return { v : switch( e ) { case A: 55; case B: 66; } };
static function main() {
trace(foo(null));
trace(foo(cast "C")); // if loaded from JSON for example
}
}
```

I wonder if some other platforms are concerned - in which case this should be fixed in Haxe - I expect both results to be `{ v : 0 }`. BTW it is not reproducible with simply "return switch"

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.