Can't call #delete() with an invalid key #4

Closed
eric opened this Issue May 7, 2012 · 3 comments

Comments

Projects
None yet
2 participants
Contributor

eric commented May 7, 2012

I just got a report of this: eric/metriks#13

It looks like the problem is that if you try to delete a key that wasn't found, it still tries to call #value on the result.

Contributor

eric commented May 7, 2012

I actually got further on it. The problem is when the key is of a different type:

https://github.com/eric/avl_tree/compare/delete-with-different-types

It looks like the problem is <=> returns nil if the types don't match, and there is no case for that.

Owner

nahi commented May 8, 2012

Ah, thanks for the investigation. We removed 'key.to_s' so <=> could return nil now.
I'm going to change trees to raise TypeError when <=> returns nil for both #insert and #delete.
Do you think it's OK for you?

Contributor

eric commented May 8, 2012

Yeah, I think that makes sense. At least I'll be able to figure out
where my bug is.

nahi closed this in da512e6 May 8, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment