Skip to content

Commit 7cc786e

Browse files
committed
[GR-20446] Fix ENV.update implementation.
PullRequest: truffleruby/1253
2 parents cbb4d72 + 7a6705f commit 7cc786e

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Bug fixes:
6767
* Fixed deprecation warning when `ENV.index` is called.
6868
* Fixed issue with `ENV.each_key`.
6969
* Fixed `ENV.replace` implementation.
70+
* Fixed `ENV.udpate` implementation.
7071

7172
Compatibility:
7273

spec/tags/core/env/update_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/main/ruby/truffleruby/core/env.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,14 @@ def to_h
295295
end
296296

297297
def update(other)
298+
return self if equal?(other)
299+
other = Truffle::Type.rb_convert_type(other, Hash, :to_hash)
298300
if block_given?
299301
other.each { |k, v| self[k] = yield(k, lookup(k), v) }
300302
else
301303
other.each { |k, v| self[k] = v }
302304
end
305+
self
303306
end
304307

305308
def keep_if(&block)

0 commit comments

Comments
 (0)