"Cannot use abstract as value" on 4.0.0-rc.5

Hello everyone, I’m having this error after upgrading to 4.0.0-rc.5. This used to work on my previous 4.0.0-rc.3. Does anyone have a hint on what can I do instead? Or is it a bug on Haxe?

The error happens on this call: Std.is(obj, Map). You can see what I’m doing in the full function below. Any help is appreciated! Cheers!

private static function objectKeys (obj: Dynamic): Array<Dynamic> {
    if (Std.is(obj, Array)) {
        var keys = new Array();
        var length: Int = ((cast (obj, Array<Dynamic>)).length);

        for (i in 0...length) {
            keys.push(i);
        }

        return keys;
    }

    if (Std.is(obj, Map)) { // Error: "Cannot use abstract as value"
        return obj.keys();
    }

    return Reflect.fields(obj);
};

It was a regression. In Haxe 3.2 you’d get the same error.
Use Std.is(obj, haxe.Constraints.IMap) instead.

1 Like

Thanks a lot for the fast response @RealyUniqueName, it works!