HaxeFoundation / haxe

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

[js] Dce removes static field with function call #10433

Open RblSb opened 3 years ago

RblSb commented 3 years ago
class Main {
    static final numbers = [];
    static function addNum(n:Int):Int {
        numbers.push(n);
        return n;
    }
    static final node = addNum(1);

    static function main() {
        trace(numbers.length); // 0
    }
}

Fine on eval.

Simn commented 3 years ago

Hmm, I vaguely remember that this is by design, but looking at it now makes me question if that design is any good...

back2dos commented 2 years ago

As mentioned in #10766, I think ideally purity would be taken into account here.