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

source_changes at macosforge.org source_changes at macosforge.org
Sat Jan 1 23:42:08 PST 2011


Revision: 5099
          http://trac.macosforge.org/projects/ruby/changeset/5099
Author:   watson1978 at gmail.com
Date:     2011-01-01 23:42:04 -0800 (Sat, 01 Jan 2011)
Log Message:
-----------
Array#delete with frozen object will not throw an exception when given a block.

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

a =  [ "a", "b", "b", "b", "c" ]
a.freeze
assert_raise(RuntimeError){ a.delete("b") }
assert_equal("not found", a.delete("z") { "not found" })

puts :ok
x}}}

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

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2011-01-02 07:42:00 UTC (rev 5098)
+++ MacRuby/trunk/array.c	2011-01-02 07:42:04 UTC (rev 5099)
@@ -1799,8 +1799,6 @@
 static bool
 rary_delete_element(VALUE ary, VALUE item, bool use_equal)
 {
-    rary_modify(ary);
-
     VALUE *p = rary_ptr(ary);
     VALUE *t = p;
     VALUE *end = p + RARY(ary)->len;
@@ -1849,6 +1847,8 @@
 	}
 	return Qnil;
     }
+
+    rary_modify(ary);
     return item;
 }
 
@@ -2838,6 +2838,7 @@
 static VALUE
 rary_compact_bang(VALUE ary, SEL sel)
 {
+    rary_modify(ary);
     return rary_delete_element(ary, Qnil, false) ? ary : Qnil;
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110101/b06859b7/attachment.html>


More information about the macruby-changes mailing list