Skip to content

Commit 54aac51

Browse files
committed
Fix ENV#clone and ENV#dup and raise TypeError
1 parent eedda85 commit 54aac51

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Compatibility:
3232
* Make `Coverage.start` and `Coverage.result` accept parameters (#3149, @mtortonesi, @andrykonchin).
3333
* Implement `rb_check_funcall()` (@eregon).
3434
* Implement `MatchData#{byteoffset,deconstruct,deconstruct_keys}` from Ruby 3.2 (#3039, @rwstauner).
35+
* Fix `ENV#{clone,dup}` and raise `TypeError` (#3039, @andrykonchin).
3536

3637
Performance:
3738

spec/tags/core/env/clone_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/tags/core/env/dup_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ def []=(key, value)
7878
end
7979
alias_method :store, :[]=
8080

81+
def clone
82+
raise TypeError, 'Cannot clone ENV, use ENV.to_h to get a copy of ENV as a hash'
83+
end
84+
8185
def delete(key)
8286
existing_value = lookup(key)
8387
if existing_value
@@ -89,6 +93,10 @@ def delete(key)
8993
existing_value
9094
end
9195

96+
def dup
97+
raise TypeError, 'Cannot dup ENV, use ENV.to_h to get a copy of ENV as a hash'
98+
end
99+
92100
def shift
93101
key = @variables.first
94102
return nil unless key

0 commit comments

Comments
 (0)