* [ruby-core:102107] [Ruby master Bug#17545] Calling dup on a subclass of Proc returns a Proc and not the subclass
@ 2021-01-15 21:26 lamont
2021-01-29 9:03 ` [ruby-core:102292] " ko1
0 siblings, 1 reply; 2+ messages in thread
From: lamont @ 2021-01-15 21:26 UTC (permalink / raw)
To: ruby-core
Issue #17545 has been reported by lamont (Lamont Granquist).
----------------------------------------
Bug #17545: Calling dup on a subclass of Proc returns a Proc and not the subclass
https://bugs.ruby-lang.org/issues/17545
* Author: lamont (Lamont Granquist)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Trivial example:
``` ruby
[1] pry(main)> class Test < Proc; end
=> nil
[3] pry(main)> Test.new { puts "foo" }.dup
=> #<Proc:0x00007f91a78913c8 (pry):3>
```
Also fairly trivial workaround:
```ruby
[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
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-core:102292] [Ruby master Bug#17545] Calling dup on a subclass of Proc returns a Proc and not the subclass
2021-01-15 21:26 [ruby-core:102107] [Ruby master Bug#17545] Calling dup on a subclass of Proc returns a Proc and not the subclass lamont
@ 2021-01-29 9:03 ` ko1
0 siblings, 0 replies; 2+ messages in thread
From: ko1 @ 2021-01-29 9:03 UTC (permalink / raw)
To: ruby-core
Issue #17545 has been updated by ko1 (Koichi Sasada).
Assignee set to ko1 (Koichi Sasada)
Status changed from Open to Assigned
This behavior is from ruby 1.9.
Matz, is it a bug?
```
@all-ruby -e 'class Test < Proc; end; p Test.new { puts "foo" }.dup.class'
:ok: 1.8
Test
:ok: 1.9 -- 98e27016c9 (2021-01-29T07:22:12Z)
Proc
```
----------------------------------------
Bug #17545: Calling dup on a subclass of Proc returns a Proc and not the subclass
https://bugs.ruby-lang.org/issues/17545#change-90147
* Author: lamont (Lamont Granquist)
* Status: Assigned
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Trivial example:
``` ruby
[1] pry(main)> class Test < Proc; end
=> nil
[3] pry(main)> Test.new { puts "foo" }.dup
=> #<Proc:0x00007f91a78913c8 (pry):3>
```
Also fairly trivial workaround:
```ruby
[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
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-29 9:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15 21:26 [ruby-core:102107] [Ruby master Bug#17545] Calling dup on a subclass of Proc returns a Proc and not the subclass lamont
2021-01-29 9:03 ` [ruby-core:102292] " ko1
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).