haxe
haxe copied to clipboard
Matching same enum twice seems to duplicate the default case.
import haxe.ds.Option;
class Test {
static function main() {
var a = [
Live,
Offline({ vct: None, ot: Some('foo') }),
Offline({ vct: Some('bar'), ot: None }),
];
switch a[Std.random(a.length)] {
case Offline({ vct: Some(v) }): trace('1 $v');
case Offline({ ot: Some(v) }): trace('2 $v');
case _:
trace("default!");
}
}
}
enum A {
Offline(v:{ vct:Option<String>, ot:Option<String> });
Live;
}
You'll find the code generated for trace("default!"") twice in the output, both with Haxe 4 and nighly.