Actions
Bug #19745
closedConfirm correct behaviour when attaching private method with `#define_singleton_method`
Bug #19745:
Confirm correct behaviour when attaching private method with `#define_singleton_method`
Description
Should dynamically added private methods be accessible publicly?
See the following example?
private def bar; end
foo = Object.new
foo.define_singleton_method(:bar, method(:bar))
foo.bar # No error.
The script above runs fine on latest Ruby HEAD. Is this correct to ignore the fact that the added method (method(:bar)
) is private?
This came up during a TruffleRuby investigation (https://github.com/oracle/truffleruby/issues/3134) where the result for the same script is: private method 'bar' called for #<Object:0xc8> (NoMethodError)
Actions