Actions
Bug #13540
closedcan't set length of shared string (RuntimeError) when interpolating __FILE__ in a heredoc
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Description
There appears to be a bug in Ruby 2.4.0 and 2.4.1 when interpolating __FILE__
inside of a heredoc. In fact, no code in this file executes when this interpolation is present. Almost as if it's a syntax error, but it's reported as a RuntimeError.
# Works in Ruby 2.3 and 2.4
puts "#{__FILE__}"
# Works in Ruby 2.3 and 2.4
x = __FILE__
puts <<~HEREDOC
#{x}
HEREDOC
# Works in Ruby 2.3
# Raises exception in Ruby 2.4: can't set length of shared string (RuntimeError)
puts <<~HEREDOC
#{__FILE__}
HEREDOC
Updated by nobu (Nobuyoshi Nakada) over 7 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r58561.
parse.y: make shared string modifiable
- parse.y (dedent_string): ensure that the string is modifiable,
not to set the length of shared string.
[ruby-core:80987] [Bug #13540]
Updated by usa (Usaku NAKAMURA) over 7 years ago
- Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) over 7 years ago
- Backport changed from 2.2: DONTNEED, 2.3: DONTNEED, 2.4: REQUIRED to 2.2: DONTNEED, 2.3: DONTNEED, 2.4: DONE
ruby_2_4 r59513 merged revision(s) 58561.
Actions
Like0
Like0Like0Like0