summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-26 11:06:17 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-26 11:06:17 +0000
commitcdbe41227d9464d592e2a85e26726b37bac83bf4 (patch)
tree7735a78669b7674cc97cffe62b62fe8594739e04
parent121b2b2802a3219821c23435f9ca8db6ff89aac1 (diff)
downloadruby-cdbe41227d9464d592e2a85e26726b37bac83bf4.tar.gz
ruby-cdbe41227d9464d592e2a85e26726b37bac83bf4.tar.xz
ruby-cdbe41227d9464d592e2a85e26726b37bac83bf4.zip
* array.c (rb_ary_cmp): Array#<=> returns nil when comparison fails
[ruby-core:26316] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--array.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 924dd9fc7..0dae1fb09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Oct 26 20:04:13 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
+
+ * array.c (rb_ary_cmp): Array#<=> returns nil when comparison fails
+ [ruby-core:26316]
+
Mon Oct 26 18:37:57 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* hash.c (default_proc_arity_check): new support function.
diff --git a/array.c b/array.c
index 05d5494af..f1927d265 100644
--- a/array.c
+++ b/array.c
@@ -2963,7 +2963,7 @@ recursive_cmp(VALUE ary1, VALUE ary2, int recur)
/*
* call-seq:
- * array <=> other_array -> -1, 0, +1
+ * array <=> other_array -> -1, 0, +1, nil
*
* Comparison---Returns an integer (-1, 0,
* or +1) if this array is less than, equal to, or greater than
@@ -2987,7 +2987,8 @@ rb_ary_cmp(VALUE ary1, VALUE ary2)
long len;
VALUE v;
- ary2 = to_ary(ary2);
+ ary2 = rb_check_array_type(ary2);
+ if (NIL_P(ary2)) return Qnil;
if (ary1 == ary2) return INT2FIX(0);
v = rb_exec_recursive_paired(recursive_cmp, ary1, ary2, ary2);
if (v != Qundef) return v;