Method comparison fails in Neko but works on JavaScript

73 Views Asked by At

I have a pretty "simple" problem.

class Main {
    public static function main()
        new Main();

    public function new() {
        var a = callbackFunc;
        var b = callbackFunc;

        if (a == b)
            trace("success");
        else
            trace("Failed");
    }

    private function callbackFunc():Void {}
}

When compiled to the JavaScript target everything is fine... in Neko it traces "Failed"... Didn't find anything useful in the net that might explain the Problem... Any ideas?

1

There are 1 best solutions below

1
On

Use Reflect.compareMethods() - this should work on all targets:

if (Reflect.compareMethods(a, b))
    trace("success");
else    
    trace("Failed");

The comparison operator is not specified to always work on functions, it depends on the target.