[#74190] [Ruby trunk Feature#12134] Comparison between `true` and `false` — duerst@...
Issue #12134 has been updated by Martin D端rst.
3 messages
2016/03/07
[#74269] Type systems for Ruby — Rob Blanco <ml@...>
Dear ruby-core,
5 messages
2016/03/10
[#74395] [Ruby trunk Feature#12142] Hash tables with open addressing — shyouhei@...
Issue #12142 has been updated by Shyouhei Urabe.
3 messages
2016/03/17
[ruby-core:74497] [Ruby trunk Bug#12206] undef_method on prepended module undefines same-name method on prepending class
From:
eugene.gilburg@...
Date:
2016-03-23 17:24:25 UTC
List:
ruby-core #74497
Issue #12206 has been updated by Eugene Gilburg.
Kazuhiro NISHIYAMA wrote:
> How about using `remove_method` instead of `undef_method` ?
It worked, thanks! Behavior is still confusing since I undef'd the method on the module rather than the class, but this solves my problem.
----------------------------------------
Bug #12206: undef_method on prepended module undefines same-name method on prepending class
https://bugs.ruby-lang.org/issues/12206#change-57618
* Author: Eugene Gilburg
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin12.0]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
1. Define a class with a method
2. Define a module with a same-name method
3. Prepend the module on the class
4. Undefine the same-name method on the module, not touching the original method on the class
5. Observe the class method to also become undefined
~~~
class MyClass
def foo
"MyClass#foo"
end
end
module MyMod
def foo
"#{super} prepended by MyMod#foo"
end
end
MyClass.prepend(MyMod)
MyClass.new.foo
# => "MyClass#foo prepended by MyMod#foo"
MyClass.instance_method(:foo) == MyMod.instance_method(:foo)
# => false
MyMod.send(:undef_method, :foo)
# The bug:
MyClass.new.foo
# => NoMethodError: undefined method `foo' for #<MyClass:0x007ffdf29614a8>
~~~
Expected behavior: `MyClass#foo` would still return "MyClass#foo" since I only undefined `foo` on the module, not on the class.
Real life use case: I'm setting up instrumentation code that can track and measure/benchmark call times of specific methods, but after it's done I want to clean up and restore original code the way it was. For me, it would be even better to support to "unprepend" a module from a class instead of undef_method on the mod, but that's more of a feature request than a bug).
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>