[前][次][番号順一覧][スレッド一覧]

ruby-changes:29337

From: charliesome <ko1@a...>
Date: Tue, 18 Jun 2013 23:01:46 +0900 (JST)
Subject: [ruby-changes:29337] charliesome:r41389 (trunk): * vm_insnhelper.c (vm_call_method): ensure methods of type

charliesome	2013-06-18 23:01:32 +0900 (Tue, 18 Jun 2013)

  New Revision: 41389

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41389

  Log:
    * vm_insnhelper.c (vm_call_method): ensure methods of type
      VM_METHOD_TYPE_ATTR_SET are called with 1 argument
    
    * test/ruby/test_module.rb (class TestModule): add test

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_module.rb
    trunk/vm_insnhelper.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41388)
+++ ChangeLog	(revision 41389)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jun 18 22:01:00 2013  Charlie Somerville  <charliesome@r...>
+
+	* vm_insnhelper.c (vm_call_method): ensure methods of type
+	  VM_METHOD_TYPE_ATTR_SET are called with 1 argument
+
+	* test/ruby/test_module.rb (class TestModule): add test
+
+	[ruby-core:55543] [Bug #8540]
+
 Tue Jun 18 22:36:23 2013  Masaya Tarui  <tarui@r...>
 
 	* gc.c (gc_profile_record_flag): reason seems like one-hot encoding.
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 41388)
+++ vm_insnhelper.c	(revision 41389)
@@ -1773,7 +1773,7 @@ vm_call_method(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1773
 		CI_SET_FASTPATH(ci, vm_call_cfunc, enable_fastpath);
 		return vm_call_cfunc(th, cfp, ci);
 	      case VM_METHOD_TYPE_ATTRSET:{
-		rb_check_arity(ci->argc, 0, 1);
+		rb_check_arity(ci->argc, 1, 1);
 		ci->aux.index = 0;
 		CI_SET_FASTPATH(ci, vm_call_attrset, enable_fastpath && !(ci->flag & VM_CALL_ARGS_SPLAT));
 		return vm_call_attrset(th, cfp, ci);
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 41388)
+++ test/ruby/test_module.rb	(revision 41389)
@@ -1167,6 +1167,14 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1167
     assert_equal(1, c.x, bug3406)
   end
 
+  def test_attr_writer_with_no_arguments
+    bug8540 = "[ruby-core:55543]"
+    c = Class.new do
+      attr_writer :foo
+    end
+    assert_raise(ArgumentError) { c.new.send :foo= }
+  end
+
   def test_private_constant
     c = Class.new
     c.const_set(:FOO, "foo")

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]