Float >> NaN in a dictionary

Tagged:
Project:GNU Smalltalk
Component:Base classes
Category:bug
Priority:normal
Assigned:Unassigned
Status:fixed
Description

Hi,

I cann add a Float >> NaN in a dictionary by the way multiple times (

st> p at: (FloatQ allInstances at: 3) put: 123
st> 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

#1 submitted by Paolo Bonzini on Fri, 06/12/2009 - 09:09

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.

#2 submitted by Paolo Bonzini on Mon, 11/02/2009 - 18:23
Status:active» fixed

Fixed in 46d1034 by refusing to hash a NaN (it works in IdentityDictionaries of course).

User login