Skip to content

Commit 8f98aae

Browse files
andrykonchineregon
authored andcommitted
[GR-45621] Fix ENV#clone and ENV#dup and raise TypeError
PullRequest: truffleruby/4132
2 parents 394532f + 54aac51 commit 8f98aae

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
@@ -35,6 +35,7 @@ Compatibility:
3535
* Implement `MatchData#{byteoffset,deconstruct,deconstruct_keys}` from Ruby 3.2 (#3039, @rwstauner).
3636
* Add `Integer#ceildiv` method (#3039, @simonlevasseur, @nirvdrum).
3737
* Implement `Class#attached_object` method (#3039, @andrykonchin).
38+
* Fix `ENV#{clone,dup}` and raise `TypeError` (#3039, @andrykonchin).
3839

3940
Performance:
4041

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)