[#99868] [Ruby master Bug#17144] Tempfile.open { ... } does not unlink the file — eregontp@...
Issue #17144 has been reported by Eregon (Benoit Daloze).
15 messages
2020/09/03
[ruby-core:100209] [Ruby master Bug#17181] Hash with default block breaks after transforming values
From:
nagachika00@...
Date:
2020-09-29 11:34:18 UTC
List:
ruby-core #100209
Issue #17181 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: REQUIRED to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONE
ruby_2_7 665589cbdf7bf652067113dd1c0bc49012b990e0 merged revision(s) df14c758fc705c49c2aaf4c9276a8f7229438fbf.
----------------------------------------
Bug #17181: Hash with default block breaks after transforming values
https://bugs.ruby-lang.org/issues/17181#change-87799
* Author: crashtech (Carlos Silva)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONE
----------------------------------------
I found a problem with Hashes that use a default proc.
```ruby
x = Hash.new { |h, k| h[k] = [] }
x[:a] << 1
x[:b] << 2
```
I expected that transforming the values as follows:
```ruby
y = x.transform_values { |arr| arr.map(&:next) }
```
should create a new array, and I should still be able to push a new element into it as follows:
```ruby
y[:c] << 3
y # => {:a=>[2], :b=>[3], :c=>[3]}
```
But the result is weird.
```ruby
y[:c] << 3 # >> TypeError (callable object is expected)
y[:c] # => the default_proc Proc object
Y[:c].call # 'h' is nil, meaning that it doesn't have the reference to the hash anymore
```
--
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>