godot
godot copied to clipboard
Do not consider NaNs equal in float values derived from Variant
Hash scalar compare for Variants which are floats no longer considers two NaN values as equal.
Closes #72222
CC @hpvb who introduced this code back in 2017 with #7815 (+ #8393).
The behavior for Dictionary with NAN keys was then later changed with #16114 to fix #16031. Would this PR reintroduce that bug?
Because of macros I would keep the parentheses around the values, just to be safe
For example: hash_compare_scalar(a&b,c) would break, not that it's likely to happen but macros are confusing
Maybe we should add a hash compare that treats NaN as equal and use it for dictionary, where we technically care about binary equality
I believe this will reintroduce the bug as it is.
Looks like this was quite a controversial series of bugs and decisions 🙂
It does look like to support both the best way I can think of is two functions. I pushed a change that addresses this with I think the least code duplication as possible and doesn't break compatibility.
I tested with the original target issue (#72222) and previous issues (#16114, #7354, #6947, #8081, #16031) and all cases seem covered.
PS: In the future, when posting a screenshot of code, please include it in Markdown as well between triple backticks (and the gdscript
syntax highlighting language) so that other people can test it easily. (This is also more accessible to screen readers.)
This makes sense to me, but hard to know if it will break something. Probably better to give it a go and be very attentive to see what happens.
I'm not sure if the memory error is a problem with the workflow. Especially because all I changed was the order of the if
conditions and it seems to be connected to Vulkan, plus I'm not able to reproduce it.
That's a race condition unrelated to this PR, it happens every now and then. I restarted the build.
I see. Thanks!
Thanks!