Actions
Bug #17545
closedCalling dup on a subclass of Proc returns a Proc and not the subclass
Description
Trivial example:
[1] pry(main)> class Test < Proc; end
=> nil
[3] pry(main)> Test.new { puts "foo" }.dup
=> #<Proc:0x00007f91a78913c8 (pry):3>
Also fairly trivial workaround:
[4] pry(main)> class Test < Proc
[4] pry(main)* def dup
[4] pry(main)* self.class.new(&super)
[4] pry(main)* end
[4] pry(main)* end
=> :dup
[5] pry(main)> Test.new { puts "foo" }.dup
=> #<Test:0x00007f91b8e73e38 (pry):9>
Seems like a bug though, Proc#dup is probably calling the ruby-c equivalent of Proc.new rather than self.class.new and bypassing subclassing
Actions
Like0
Like0Like0Like0Like0