semantic
semantic copied to clipboard
Bug when sorting an enumerable that includes nil
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.
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?
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
Thanks for the update @vmeyet. I'll take a look at this today and hopefully cut a new version with the fix.