Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the appropriate Variant hash and compare functions for Dictionaries #16114

Merged
merged 1 commit into from
Jan 27, 2018

Conversation

hpvb
Copy link
Member

@hpvb hpvb commented Jan 27, 2018

Dictionaires did not use the VariantHasher and VariantComparator making
them unsafe for use with NaN values as keys. This PR uses the
appropriate Variant implementations for these functions.

   var d = {}
   d[Vector2(NAN, NAN)] = 0
   d[Vector2(NAN, NAN)] = 0
   print(d.size())

will now output '1' and not '2'

This fixes #16031

Dictionaires did not use the VariantHasher and VariantComparator making
them unsafe for use with NaN values as keys. This PR uses the
appropriate Variant implementations for these functions.

   var d = {}
   d[Vector2(NAN, NAN)] = 0
   d[Vector2(NAN, NAN)] = 0
   print(d.size())

will now output '1' and not '2'

This fixes godotengine#16031
@hpvb hpvb added this to the 3.0 milestone Jan 27, 2018
@akien-mga akien-mga modified the milestones: 3.0, 3.1 Jan 27, 2018
@akien-mga akien-mga merged commit 1fb18f1 into godotengine:master Jan 27, 2018
@hpvb hpvb deleted the fix-16031 branch February 27, 2018 21:22
puchik added a commit to puchik/godot that referenced this pull request Aug 31, 2023
Hash comparison for Variant continues to perform semantic/logical comparison with NaN's considered equal by default (to prevent godotengine#16114, godotengine#7354, godotengine#6947, godotengine#8081), but now optionally allows for numeric comparison that does not consider NaN's equal to support proper value comparison (for godotengine#72222)
mandryskowski pushed a commit to mandryskowski/godot that referenced this pull request Oct 11, 2023
Hash comparison for Variant continues to perform semantic/logical comparison with NaN's considered equal by default (to prevent godotengine#16114, godotengine#7354, godotengine#6947, godotengine#8081), but now optionally allows for numeric comparison that does not consider NaN's equal to support proper value comparison (for godotengine#72222)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dictionary identity is broken for NAN
2 participants