[ruby-core:65228] [ruby-trunk - 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

From: nobu@...
Date: 2014-09-23 00:30:18 UTC
List: ruby-core #65228
Issue #10283 has been updated by Nobuyoshi Nakada.

Related to Bug #10259: send を使った attr_writer への書き込みができない場合がある added

----------------------------------------
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
https://bugs.ruby-lang.org/issues/10283#change-49060

* Author: Jeremy Evans
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: current: 2.2.0
* ruby -v: ruby 2.2.0preview1 (2014-09-17 trunk 47616) [i386-openbsd]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
This raises a NoMethodError in ruby 2.2.0preview1:

  ruby -e "class A; define_method('b='.to_sym){|v|}; end; A.new.b = 1"

This does not, showing it is specific to dynamic symbols:

  ruby -e "class A; define_method(:b=){|v|}; end; A.new.b = 1"

This does not, showing it is specific to symbols ending in =:

  ruby -e "class A; define_method('b'.to_sym){}; end; A.new.b"

This does not, showing it works when called via send:

  ruby -e "class A; define_method('b='.to_sym){|v|}; end; A.new.send(:b=, 1)"

This does not, showing it works after calling send:

  ruby -e "class A; define_method('b='.to_sym){|v|}; end; A.new.send(:b=, 1); A.new.b = 1"

I apologize if this is already fixed in trunk.



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

In This Thread

Prev Next