Issue #7773 has been updated by mame (Yusuke Endoh).

Status changed from Open to Assigned
Assignee set to nobu (Nobuyoshi Nakada)

gaffneyc (Chris Gaffney) wrote:
> I consider it a bug because the behavior only happens using `send`.

Actually, it is not a bug itself.
An assignment-like method call always returns its right value rather than the return value from the method.
The following code shows the difference:

  class Foo
    def foo=(x)
      "foo"
    end
  end
  x = Foo.new
  p(x.foo = 42)        #=> 42
  p(x.send(:foo=, 42)) #=> "foo"


However, as MarcAndre said, a method defined by attr_accessor used to return its argument, at least in ruby 1.9.3p194.
There seems to be a regression.  Nobu, could you investigate it?

-- 
Yusuke Endoh <mame / tsg.ne.jp>
----------------------------------------
Bug #7773: Calling send("attribute=", value) returns nil instead of value
https://bugs.ruby-lang.org/issues/7773#change-35927

Author: gaffneyc (Chris Gaffney)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: core
Target version: 2.0.0
ruby -v: 2.0.0-rc1


When calling an attribute writer created using either attr_accessor or attr_writer via send nil is returned from the send call instead of the new value.

I've attached a test case that is failing on current head (51794) and 2.0.0-rc1. I've done a git bisect and it looks like commit 37228 (db1e99cd) is the first offending commit.

I've been able to reproduce on OS X 10.8 and Ubuntu 12.04.


-- 
http://bugs.ruby-lang.org/