[ruby-core:65229] [ruby-trunk - Bug #10283] [Closed] 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:31:51 UTC
List: ruby-core #65229
Issue #10283 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Closed
Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED

----------------------------------------
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-49062

* Author: Jeremy Evans
* Status: Closed
* 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: DONTNEED, 2.1: DONTNEED
----------------------------------------
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