From: kylerippey@...
Date: 2017-05-03T06:29:52+00:00
Subject: [ruby-core:80987] [Ruby trunk Bug#13540] can't set length of shared string (RuntimeError) when interpolating __FILE__ in a heredoc

Issue #13540 has been reported by kylerippey (Kyle Rippey).

----------------------------------------
Bug #13540: can't set length of shared string (RuntimeError) when interpolating __FILE__ in a heredoc
https://bugs.ruby-lang.org/issues/13540

* Author: kylerippey (Kyle Rippey)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
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.

~~~ ruby
# 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
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>