[ruby-core:65292] [ruby-trunk - Bug #10299] alias_method :new_foo=, :"#{:foo}=" doesn't work properly on ruby 2.2.0preview1.

From: nobu@...
Date: 2014-09-27 12:29:55 UTC
List: ruby-core #65292
Issue #10299 has been updated by Nobuyoshi Nakada.

Duplicates Bug #10283: Calling define_method with a dynamic symbol ending in = results in a NoMethodError when calling the method via assignment, until called via send added

----------------------------------------
Bug #10299: alias_method :new_foo=, :"#{:foo}="  doesn't work properly on ruby 2.2.0preview1.
https://bugs.ruby-lang.org/issues/10299#change-49116

* Author: Norimasa Ando
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0preview1 (2014-09-17 trunk 47616) [x86_64-darwin12.0]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
Here is reproducible script.

~~~ruby
class Test
  class << self
    def test
      alias_method :new_foo=, :"#{:foo}="
    end
  end
  attr_accessor :foo
  test
end
~~~

It occurs following error.

~~~
NameError: undefined method `foo=' for class `Test'
from /Users/ando_norimasa/a.rb:4:in `alias_method'
~~~

I expect it works without error.



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

In This Thread

Prev Next