[#104307] Float truncate — Eustáquio Rangel <eustaquiorangel@...>
Hi!
4 messages
2021/06/16
[ruby-core:104195] [Ruby master Bug#17767] `Cloned ENV` inconsistently returns `ENV` or `self`
From:
merch-redmine@...
Date:
2021-06-07 18:27:13 UTC
List:
ruby-core #104195
Issue #17767 has been updated by jeremyevans0 (Jeremy Evans).
At the May 2021 developer meeting, it was decided that `ENV.dup` should raise and `ENV.clone` should warn, so I closed my previous pull request and added a pull request for that behavior: https://github.com/ruby/ruby/pull/4557
----------------------------------------
Bug #17767: `Cloned ENV` inconsistently returns `ENV` or `self`
https://bugs.ruby-lang.org/issues/17767#change-92375
* Author: kachick (Kenichi Kamiya)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
GH-PR: https://github.com/ruby/ruby/pull/4344
Is this an expected behavior?
```console
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]
```
```ruby
cloned_env = ENV.clone
p ENV.each_key{}.equal?(ENV) #=> true
p cloned_env.each_key{}.equal?(cloned_env) #=> true
ENV.delete('TEST')
err = ENV.fetch('TEST') rescue $!
p err.receiver.equal?(ENV) #=> true
err = cloned_env.fetch('TEST') rescue $!
p err.receiver.equal?(cloned_env) #=> false
ENV['TEST'] = 'TRUE'
p ENV.select!{ false }.equal?(ENV) #=> true
cloned_env['TEST'] = 'TRUE'
p cloned_env.select!{ false }.equal?(cloned_env) #=> false
```
I guess ruby don't care `Cloned ENV` objects.
Yes, anyone basically do not write these code.
But the behaviors looks weird to me.
Should block to clone?
Should return ENV?
Should return self?
I think `they return self` makes consistently behaviors and does not break compatibilities.
So I have created this PR
--
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>