Skip to content

Commit 660c5e5

Browse files
committed
File#path should return a new mutable String on every call
* Fixes #2115
1 parent 32fbe9f commit 660c5e5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Compatibility:
4343
* Implement negative line numbers for eval (#1482).
4444
* Support refinements for `#to_s` called by string interpolation (#2110, @ssnickolay)
4545
* Module#using raises error in method scope (#2112, @ssnickolay)
46+
* `File#path` now returns a new mutable String on every call like MRI (#2115).
4647

4748
Performance:
4849

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ module Constants
108108
PATH_SEPARATOR = ':'
109109
POSIX = Truffle::POSIX
110110

111-
attr_reader :path
112-
113111
# The mode_t type is 2 bytes (ushort). Instead of getting whatever
114112
# value happens to be in the least significant 16 bits, just set
115113
# the value to 0 if it is greater than 0xffff. Also, negative values
@@ -1238,6 +1236,9 @@ def stat
12381236
Stat.fstat Primitive.io_fd(self)
12391237
end
12401238

1239+
def path
1240+
@path.dup
1241+
end
12411242
alias_method :to_path, :path
12421243

12431244
def truncate(length)

0 commit comments

Comments
 (0)