[ruby-core:66741] [ruby-trunk - Bug #10578] [Open] Allow undefining methods in refinements

From: whitequark@...
Date: 2014-12-08 10:09:28 UTC
List: ruby-core #66741
Issue #10578 has been reported by Peter Zotov.

----------------------------------------
Bug #10578: Allow undefining methods in refinements
https://bugs.ruby-lang.org/issues/10578

* Author: Peter Zotov
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
Since refinements are locally scoped monkey patches, and it is possible and useful to undef a method globally, I think refinements should allow to undef methods as well as def them.

For example:

~~~ ruby
module NoPlus
  refine String do
    undef +
  end
end

using NoPlus
"a" + "b"
~~~

Expected behavior: undefined method `+' for "a":String
Actual behavior: undef ignored



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

In This Thread

Prev Next