diff options
| author | Koichi Sasada <ko1@atdot.net> | 2021-02-18 17:10:39 +0900 |
|---|---|---|
| committer | Koichi Sasada <ko1@atdot.net> | 2022-01-13 17:43:14 +0900 |
| commit | 7e21b77dc6bfefaf331a0dbf89782303b8cda05d (patch) | |
| tree | 53de2f22527722e03837f2528448293dfe840e7a | |
| parent | 5a75151a0166ded78fc87ef5891a6877ba0950db (diff) | |
T#dup (T < Proc) should return T's object
T#dup (T < Proc) returns Proc object (not T) from Ruby 1.9.
[Bug #17545]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4197
| -rw-r--r-- | test/ruby/test_proc.rb | 5 | ||||
| -rw-r--r-- | vm.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 05b2493b24..392b6be665 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -412,6 +412,11 @@ class TestProc < Test::Unit::TestCase assert_equal(:foo, bc.foo) end + def test_dup_subclass + c1 = Class.new(Proc) + assert_equal c1, c1.new{}.dup.class, '[Bug #17545]' + end + def test_binding b = proc {|x, y, z| proc {}.binding }.call(1, 2, 3) class << b; attr_accessor :foo; end @@ -994,7 +994,7 @@ rb_proc_dup(VALUE self) rb_proc_t *src; GetProcPtr(self, src); - procval = proc_create(rb_cProc, &src->block, src->is_from_method, src->is_lambda); + procval = proc_create(rb_obj_class(self), &src->block, src->is_from_method, src->is_lambda); if (RB_OBJ_SHAREABLE_P(self)) FL_SET_RAW(procval, RUBY_FL_SHAREABLE); RB_GC_GUARD(self); /* for: body = rb_proc_dup(body) */ return procval; |
