ruby-changes:27069
From: marcandre <ko1@a...>
Date: Thu, 7 Feb 2013 02:31:33 +0900 (JST)
Subject: [ruby-changes:27069] marcandRe: r39121 (trunk): * vm_insnhelper.c: attr_writer should return its argument [Bug #7773]
marcandre 2013-02-07 02:31:22 +0900 (Thu, 07 Feb 2013) New Revision: 39121 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39121 Log: * vm_insnhelper.c: attr_writer should return its argument [Bug #7773] * test/ruby/test_basicinstructions.rb: Test for above Modified files: trunk/ChangeLog trunk/test/ruby/test_basicinstructions.rb trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 39120) +++ ChangeLog (revision 39121) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Feb 7 02:31:10 2013 Marc-Andre Lafortune <ruby-core@m...> + + * vm_insnhelper.c: attr_writer should return its argument [Bug #7773] + + * test/ruby/test_basicinstructions.rb: Test for above + Thu Feb 7 01:35:00 2013 Zachary Scott <zachary@z...> * doc/security.rdoc: Link to japanese version of CVE page patch by Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 39120) +++ vm_insnhelper.c (revision 39121) @@ -549,7 +549,7 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_c https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L549 return rb_ivar_get(obj, id); } -static inline void +static inline VALUE vm_setivar(VALUE obj, ID id, VALUE val, IC ic, rb_call_info_t *ci, int is_attr) { #if USE_IC_FOR_IVAR @@ -572,7 +572,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L572 if (index < len) { ptr[index] = val; - return; /* inline cache hit */ + return val; /* inline cache hit */ } } else { @@ -592,7 +592,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L592 } } #endif /* USE_IC_FOR_IVAR */ - rb_ivar_set(obj, id, val); + return rb_ivar_set(obj, id, val); } static VALUE @@ -1540,9 +1540,9 @@ vm_call_ivar(rb_thread_t *th, rb_control https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1540 static VALUE vm_call_attrset(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci) { - vm_setivar(ci->recv, ci->me->def->body.attr.id, *(cfp->sp - 1), 0, ci, 1); + VALUE val = vm_setivar(ci->recv, ci->me->def->body.attr.id, *(cfp->sp - 1), 0, ci, 1); cfp->sp -= 2; - return Qnil; + return val; } static inline VALUE Index: test/ruby/test_basicinstructions.rb =================================================================== --- test/ruby/test_basicinstructions.rb (revision 39120) +++ test/ruby/test_basicinstructions.rb (revision 39121) @@ -502,6 +502,7 @@ class TestBasicInstructions < Test::Unit https://github.com/ruby/ruby/blob/trunk/test/ruby/test_basicinstructions.rb#L502 class OP attr_reader :x + attr_accessor :foo def x=(x) @x = x :Bug1996 @@ -602,6 +603,17 @@ class TestBasicInstructions < Test::Unit https://github.com/ruby/ruby/blob/trunk/test/ruby/test_basicinstructions.rb#L603 assert_equal 4, x[0] end + def test_send_opassing + bug7773 = '[ruby-core:51821]' + x = OP.new + assert_equal 42, x.foo = 42, bug7773 + assert_equal 42, x.foo, bug7773 + assert_equal -6, x.send(:foo=, -6), bug7773 + assert_equal -6, x.foo, bug7773 + assert_equal :Bug1996, x.send(:x=, :case_when_setter_returns_other_value), bug7773 + assert_equal :case_when_setter_returns_other_value, x.x, bug7773 + end + def test_backref /re/ =~ 'not match' assert_nil $~ @@ -683,5 +695,4 @@ class TestBasicInstructions < Test::Unit https://github.com/ruby/ruby/blob/trunk/test/ruby/test_basicinstructions.rb#L695 assert_equal [], [*a] assert_equal [1], [1, *a] end - end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/