HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.19k stars 656 forks source link

[analyzer] Some mess with something #7765

Open Simn opened 5 years ago

Simn commented 5 years ago
class Main {
    @:analyzer(full_debug)
    static function main() {
        new Main(0).add(pipe(new Main(1))).add(pipe(new Main(2)));
    }

    @:pure(false) function add(m:Main) return this;

    function new(i:Int) { }

    static inline function pipe(m:Main) return m;
}

Generated JS:

Main.main = function() {
    var m = new Main(2);
    new Main(0).add(new Main(1)).add(m);
};

C'est la merde...

Simn commented 5 years ago

Different example:

class Main {
    @:analyzer(no_fusion)
    static function main() {
        new Main(0).add({var m = new Main(1); m; });
    }

    @:pure(false) function add(m1:Main) return this;

    function new(i:Int) { }
}

Generated JS:

Main.main = function() {
    var m = new Main(1);
    new Main(0).add(m);
};

I think something weird is going on with purity inference because -D analyzer-no-purity-inference fixes it.

Simn commented 1 year ago

Had to revert that fix because some targets are failing. This probably suggests that they have some other kind of problem, but I won't be able to deal with all that in time for 4.3.

kLabz commented 1 year ago

C'est la merde...