-
Notifications
You must be signed in to change notification settings - Fork 78
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
PersistentHashMap.containsKey is broken for null values #85
Comments
I think this is an issue with the HashMap architecture, and probably has a similar issue with keys. The other alternative is to find an elegant way to prevent option types. |
Thanks.
Or if the (potential) performance is a problem, we could just exception guard the add function. On your suggestion of preventing option types, we could add a It is a shame that F# has a |
This is terrible. It is quite disappointing when the Option type fails at the only thing it's meant to do. Hope it gets fixed.
|
It looks to me like the problem here is with INode.find. Note that Clojure has two overloads for this method; the one used for containsKey takes a distinct NOT_FOUND object which is used to detect when the key is not found. Anyway, it looks like INode.find (in current FSharpx.Collections) is only ever used by ContainsKey, so why not change the result type of INode.find to bool and make the appropriate changes to the node implementations? Since INode is internal to the library, I believe that shouldn't be a breaking change. |
PersistentHashMap.containsKey returns false negatives, if the value of the key-value pair is null.
This can also manifest if the value is None, or the value is unit. In fact, I discovered this because I was trying to treat PersistentHashMap<'a, unit> like a persistent hash set. This is because, internally, .NET stores None and unit as null.
Example:
The text was updated successfully, but these errors were encountered: