Skip to content
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

Bug when sorting an enumerable that includes nil #13

Open
perlun opened this issue Apr 28, 2015 · 3 comments
Open

Bug when sorting an enumerable that includes nil #13

perlun opened this issue Apr 28, 2015 · 3 comments
Assignees
Labels

Comments

@perlun
Copy link
Contributor

perlun commented Apr 28, 2015

This is what I get:

rake aborted!
TypeError: can't dup NilClass
/Library/Ruby/Gems/2.0.0/gems/semantic-1.4.1/lib/semantic/version.rb:52:in `dup'
/Library/Ruby/Gems/2.0.0/gems/semantic-1.4.1/lib/semantic/version.rb:52:in `<=>'
/Users/plundberg/git/mforms-addons-platform/Rakefile:25:in `sort'

Too lazy/busy to make a failing spec for it at the moment, but it should be trivial. IMHO, comparing "anything" to nil should always return 1, i.e. "anything" is higher than nil.

@jlindsey jlindsey added the bug label Nov 8, 2016
@jlindsey
Copy link
Owner

jlindsey commented Nov 8, 2016

Hey @perlun I know this is a million years late but is this still an issue? If so could I bother you for an example?

@vmeyet
Copy link
Contributor

vmeyet commented Nov 14, 2016

This is still an issue:

nil == Semantic::Version.new('1.0.0')
# false

Semantic::Version.new('1.0.0') == nil
# TypeError: can't dup NilClass   // v1.4.1
# NoMethodError: undefined method `major' for nil:NilClass   // v1.5.0

Semantic::Version.new('1.0.0') > nil
# TypeError: can't dup NilClass   // v1.4.1
# NoMethodError: undefined method `major' for nil:NilClass   // v1.5.0

Caused by the spaceship (<=>) operator not handling nil case

[updated] the errors are not the same with the version 1.4.x and 1.5.0

@jlindsey
Copy link
Owner

Thanks for the update @vmeyet. I'll take a look at this today and hopefully cut a new version with the fix.

@jlindsey jlindsey self-assigned this Nov 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants