[#67346] Future of test suites for Ruby — Charles Oliver Nutter <headius@...>

I'll try to be brief so we can discuss all this. tl;dr: RubySpec is

19 messages 2015/01/05

[ruby-core:67604] [ruby-trunk - Bug #10744] Kernel#singleton_method returns refined method

From: hanachin@...
Date: 2015-01-15 12:12:22 UTC
List: ruby-core #67604
Issue #10744 has been updated by Seiei Higa.

File 0001-proc.c-Kernel-singleton_method-should-not-use-refine.patch added

i wrote a patch for this.

----------------------------------------
Bug #10744: Kernel#singleton_method returns refined method
https://bugs.ruby-lang.org/issues/10744#change-51022

* Author: Seiei Higa
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-01-15 trunk 49258) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Kernel#singleton_method is an [indirect method access](https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/RefinementsSpec).
it should not return `Method` object like Kernel#method.

following code does not works as I expected in ruby-trunk, 2.2.0, 2.1.5

``` ruby
class C
end

module RefinementBug
  refine C.singleton_class do
    def foo
    end
  end
end

p C.singleton_method(:foo)
p C.singleton_method(:foo).call

# expected:
#   refined_singleton_method.rb:11:in `singleton_method': undefined singleton method `foo' for `C' (NameError)
#   from refined_singleton_method.rb:11:in `<main>'
#
# actual:
#   #<Method: C.foo>
#   bug.rb:35:in `call': super: no superclass method `foo' for C:Class (NoMethodError)
#   from bug.rb:35:in `<main>'
```


---Files--------------------------------
0001-proc.c-Kernel-singleton_method-should-not-use-refine.patch (1.78 KB)


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

In This Thread

Prev Next