HaxeFoundation / haxe

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

[hl] add -D hl_w_null_compare #11640

Closed yuxiaomao closed 2 months ago

yuxiaomao commented 2 months ago

I'm trying to add a new flag -D hl_w_null_compare which will gives a warning where we have done null comparison instead of implicitly convert to 0. It can help existing hl code check theirs comparison before moving to the newer version. Related commits:

This code works correctly during the build, however, when running inside VSCode and open the file from the "PROBLEMS" section after build, the warning disappear after a small delay (probably some rebuild on the specific file happens). It does not impact all files, at least not std files. @kLabz du you have any idea on how to prevent the warning been removed?

kLabz commented 2 months ago

Other than disabling diagnostics, probably no way atm since the warning comes from generator so won't happen in diagnostics :/

yuxiaomao commented 2 months ago

Thanks for pointing out the diagnostics feature! I did not know it before. My PR is only a tool for upgrading new haxe version, disable temporary diagnostics is totally acceptable. So for now I have this: "haxe.enableDiagnostics": false in settings.json -D hl_w_null_compare in build.hxml

I'll check with the dev team to see if this fit theirs need

yuxiaomao commented 2 months ago

No one says no, so I'll merge it!

kLabz commented 2 months ago

Not sure we'll want to keep it as is for long, since warnings in generators should be avoided as much as possible :/

yuxiaomao commented 2 months ago

I think it's an interesting tools for other hl project pass to haxe 5.0 - It can be a warning before generator but I don't think other target are concerned in this specific case? Note: This commit can be revert safely.