Ticket #1691 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

Data.Map.deleteAt broken with index 0

Reported by: guest Owned by:
Priority: normal Milestone:
Component: libraries/base Version: 6.6.1
Keywords: Cc: jgoerzen@…
Operating System: Linux Architecture: x86
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Take a look at this ghci session:

Prelude> :m Data.Map
Prelude Data.Map> Data.Map.deleteAt 0 (Data.Map.fromList [(0::Int, 0::Int), (1,1), (2, 2), (3, 3)])
fromList []
Prelude Data.Map> Data.Map.elemAt 0 (Data.Map.fromList [(0::Int, 0::Int), (1,1), (2, 2), (3, 3)])
(0,0)

In other words, deleteAt with index 0 deletes *everything* in the map, not just the first element in it.

Prelude Data.Map> Data.Map.deleteAt 1 (Data.Map.fromList [(0::Int, 0::Int), (1,1), (2, 2), (3, 3)])
fromList [(0,0),(2,2),(3,3)]

That appears to work as it should. It seems that there is something wrong with an index of 0.

Change History

Changed 6 years ago by guest

it looks like updateAt also has this problem.

Changed 6 years ago by guest

It's not just index 0, that's just an easy way to replicate it.

Step through the indices and you'll find quite a few wrong results.

Changed 6 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Thanks for the report.

This works in the HEAD for me. It sounds like another example of  http://haskell.org/pipermail/libraries/2007-July/007785.html

Note: See TracTickets for help on using tickets.