[macruby-changes] [1770] MacRuby/branches/experimental/array.c
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jun 5 21:46:04 PDT 2009
Revision: 1770
http://trac.macosforge.org/projects/ruby/changeset/1770
Author: lsansonetti at apple.com
Date: 2009-06-05 21:46:03 -0700 (Fri, 05 Jun 2009)
Log Message:
-----------
Array#push: raise an exception if the receiver cannot be modified, even if there is nothing to push
Modified Paths:
--------------
MacRuby/branches/experimental/array.c
Modified: MacRuby/branches/experimental/array.c
===================================================================
--- MacRuby/branches/experimental/array.c 2009-06-06 02:52:50 UTC (rev 1769)
+++ MacRuby/branches/experimental/array.c 2009-06-06 04:46:03 UTC (rev 1770)
@@ -478,9 +478,16 @@
static VALUE
rb_ary_push_m(VALUE ary, SEL sel, int argc, VALUE *argv)
{
- while (argc--) {
- rb_ary_push(ary, *argv++);
+ if (argc == 0) {
+ // Even if there is nothing to push, we still need to check if the
+ // receiver can be modified, to conform to RubySpec.
+ rb_ary_modify(ary);
}
+ else {
+ while (argc--) {
+ rb_ary_push(ary, *argv++);
+ }
+ }
return ary;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090605/2044f33f/attachment.html>
More information about the macruby-changes
mailing list