haxe icon indicating copy to clipboard operation
haxe copied to clipboard

DCE shouldn't remove static calls to impure functions (fixes #10433)

Open bendmorris opened this issue 3 years ago • 3 comments

There are some missing @:pure annotations in the std lib, which I noticed after fixing this as some unnecessary static vars would now be preserved. Fixed the ones I noticed.

Fixes #10433

bendmorris avatar Dec 01 '22 04:12 bendmorris

Hmm, some of these might be controversial because of exceptions. For instance, isDirectory is documented to throw an exception in some cases, so something like this could be a pattern:

try {
    FileSystem.isDirectory(something);
    // do something else
} catch(e) {
    // handle case where it's not a directory
}

If the optimizer removes the call because it is considered pure, we end up with changed behavior.

Simn avatar Dec 01 '22 09:12 Simn

Fair point; I pared the @:pure annotations down to be more conservative.

bendmorris avatar Dec 01 '22 14:12 bendmorris

@kLabz Could you double check these @:pure(false) additions? I'm fine with merging this if there's no further potential problems.

Simn avatar Mar 25 '23 07:03 Simn

Unfortunately, this PR never got updated and would need further work, so I'll have to close it.

Simn avatar Apr 05 '25 18:04 Simn