[macruby-changes] [5177] MacRuby/trunk/array.c

source_changes at macosforge.org source_changes at macosforge.org
Mon Jan 17 05:17:38 PST 2011


Revision: 5177
          http://trac.macosforge.org/projects/ruby/changeset/5177
Author:   watson1978 at gmail.com
Date:     2011-01-17 05:17:32 -0800 (Mon, 17 Jan 2011)
Log Message:
-----------
Array#[]= will check frozen before attempting to coerce arguments.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

ary = [ 1, 2, 3 ].freeze
assert_raise(RuntimeError){ ary[0] = 4 }
assert_raise(RuntimeError){ ary[:foo] = 4 }
assert_raise(RuntimeError){ ary[:foo, :bar] = 4 }

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/array.c

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2011-01-17 08:48:04 UTC (rev 5176)
+++ MacRuby/trunk/array.c	2011-01-17 13:17:32 UTC (rev 5177)
@@ -985,12 +985,14 @@
     long offset, beg, len;
 
     if (argc == 3) {
+	rary_modify(ary);
 	rary_splice(ary, NUM2LONG(argv[0]), NUM2LONG(argv[1]), argv[2]);
 	return argv[2];
     }
     if (argc != 2) {
 	rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
     }
+    rary_modify(ary);
     if (FIXNUM_P(argv[0])) {
 	offset = FIX2LONG(argv[0]);
     }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110117/9ec7c142/attachment.html>


More information about the macruby-changes mailing list