HaxeFoundation / hashlink

A virtual machine for Haxe
https://hashlink.haxe.org/
MIT License
812 stars 158 forks source link

Unexpected implicit cast to Int, from `abstract(Null<Int>)` #696

Closed Geokureli closed 4 months ago

Geokureli commented 4 months ago

Example:

class Test {
    static var foo:Foo = null;

    static function main() {
        trace(switch (foo) {
            case B: "B";
            case A: "A";
            default: "B";
        });
        // Outputs "A" only on hashlink, otherwise B
    }
}

enum abstract Foo(Null<Int>) {
    public var A = 0;
    public var B = 1;
}

looks as though an int cast is converting null to 0, despite that null is a valid value for foo. We were able to work around this by adding case null: up top, but still seems like a bug

yuxiaomao commented 4 months ago

Fixed in haxe

Geokureli commented 4 months ago

Thanks!