Float >> NaN in a dictionary
| Project: | GNU Smalltalk |
| Component: | Base classes |
| Category: | bug |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | fixed |
Hi,
I cann add a Float >> NaN in a dictionary by the way multiple times (
st> p at: (FloatQ allInstances at: 3) put: 123st> p at: (FloatQ allInstances at: 3) put: 123
st> p at: (FloatQ allInstances at: 3) put: 123
st> p
Dictionary (
NaN->123
NaN->123
NaN->123)
)
But when I try to acces to it, it failed :
Object: Dictionary new: 32 "<0x2b1783097a40>" error: Invalid argument Inf: key not found
SystemExceptions.NotFound(Exception)>>signal
SystemExceptions.NotFound(Exception)>>signal:
SystemExceptions.NotFound class>>signalOn:what:
[] in Dictionary>>at:
Dictionary>>at:ifAbsent:
Dictionary>>at:
UndefinedObject>>executeStatements
Updates
I'd say it does not make much sense. Given that NaNs are ~= to themselves, you cannot do anything with them in an equality-based hash table (only in a identity-based one).
Were you just playing with fire or did you get into this in some real-world case?
I wonder how much if anything would be broken by making Float>>#hash raise an exception for NaNs.
| Status: | active | » fixed |
Fixed in 46d1034 by refusing to hash a NaN (it works in IdentityDictionaries of course).
