[#103241] [Ruby master Bug#17777] 2.6.7 fails to build on macOS: implicit declaration of function 'rb_native_mutex_destroy' is invalid in C99 — eregontp@...
Issue #17777 has been reported by Eregon (Benoit Daloze).
17 messages
2021/04/05
[#103305] [Ruby master Feature#17785] Allow named parameters to be keywords — marcandre-ruby-core@...
Issue #17785 has been reported by marcandre (Marc-Andre Lafortune).
21 messages
2021/04/08
[#103342] [Ruby master Feature#17790] Have a way to clear a String without resetting its capacity — jean.boussier@...
Issue #17790 has been reported by byroot (Jean Boussier).
14 messages
2021/04/09
[#103388] [ANN] Multi-factor Authentication of bugs.ruby-lang.org — SHIBATA Hiroshi <hsbt@...>
Hello,
5 messages
2021/04/12
[#103414] Re: [ANN] Multi-factor Authentication of bugs.ruby-lang.org
— Martin J. Dürst <duerst@...>
2021/04/13
Is there a way to use this multi-factor authentication for (like me)
[#103547] List of CI sites to check — Martin J. Dürst <duerst@...>
Hello everybody,
4 messages
2021/04/22
[#103596] [Ruby master Feature#17830] Add Integer#previous and Integer#prev — rafasoaresms@...
Issue #17830 has been reported by rafasoares (Rafael Soares).
9 messages
2021/04/26
[ruby-core:103231] [Ruby master Bug#17321] Having a singleton class makes cloning imperfect
From:
usa@...
Date:
2021-04-05 00:19:09 UTC
List:
ruby-core #103231
Issue #17321 has been updated by usa (Usaku NAKAMURA).
Backport changed from 2.5: REQUIRED, 2.6: REQUIRED, 2.7: DONE to 2.5: REQUIRED, 2.6: DONE, 2.7: DONE
ruby_2_6 r67935 merged revision(s) ebb96fa8808317ad53a4977bff26cf755d68077e.
----------------------------------------
Bug #17321: Having a singleton class makes cloning imperfect
https://bugs.ruby-lang.org/issues/17321#change-91309
* Author: ufuk (Ufuk Kayserilioglu)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0dev (2020-11-11T09:11:09Z master fa3670e6e4) [x86_64-darwin19]
* Backport: 2.5: REQUIRED, 2.6: DONE, 2.7: DONE
----------------------------------------
## Problem
---
Running the following reproduction script:
```ruby
class Foo
def self.foo; end
end
def report(klass, name)
puts " #{name}.instance_methods(false): #{klass.instance_methods(false)}"
end
def clone_and_compare(obj)
cln = obj.clone
report(obj.singleton_class, "obj.singleton_class")
report(cln.singleton_class, "cln.singleton_class")
report(obj.singleton_class.singleton_class, "obj.singleton_class.singleton_class")
report(cln.singleton_class.singleton_class, "cln.singleton_class.singleton_class")
end
puts "## Case 1"
obj = Foo.new
clone_and_compare(obj)
puts "## Case 2"
obj = Foo.new
obj.singleton_class
clone_and_compare(obj)
puts "## Case 3"
obj = Foo.new
obj.singleton_class.singleton_class.send(:define_method, :method_on_s2) {}
clone_and_compare(obj)
```
gives the following output:
```
## Case 1
obj.singleton_class.instance_methods(false): []
cln.singleton_class.instance_methods(false): []
obj.singleton_class.singleton_class.instance_methods(false): []
cln.singleton_class.singleton_class.instance_methods(false): []
## Case 2
obj.singleton_class.instance_methods(false): []
cln.singleton_class.instance_methods(false): []
obj.singleton_class.singleton_class.instance_methods(false): []
cln.singleton_class.singleton_class.instance_methods(false): [:foo]
## Case 3
obj.singleton_class.instance_methods(false): []
cln.singleton_class.instance_methods(false): []
obj.singleton_class.singleton_class.instance_methods(false): [:method_on_s2]
cln.singleton_class.singleton_class.instance_methods(false): [:method_on_s2]
```
`Case 2` is surprising, because the cloned object has different contents to the original.
It is surprising that `clone.singleton_class.singleton_class` has the method `:foo` whereas
`obj.singleton_class.singleton_class` does not have any methods.
`Case 3` suggests, however, that `clone.singleton_class.singleton_class` should have the
same methods as the ones on `obj.singleton_class.singleton_class`.
This reproduction script gives the same output all the way from Ruby 2.0 up to Ruby-HEAD:
https://wandbox.org/permlink/hRM9OMgtd6nuscRz
## Fix
---
@alanwu and me have put together a PR that makes `Case 2` output identical to `Case 1` output:
https://github.com/ruby/ruby/pull/3761
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>