haxe
haxe copied to clipboard
DCE shouldn't remove static calls to impure functions (fixes #10433)
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
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.
Fair point; I pared the @:pure annotations down to be more conservative.
@kLabz Could you double check these @:pure(false) additions? I'm fine with merging this if there's no further potential problems.
Unfortunately, this PR never got updated and would need further work, so I'll have to close it.