diff options
-rw-r--r-- | parse.y | 6 | ||||
-rw-r--r-- | test/ruby/test_parse.rb | 10 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 16 insertions, 2 deletions
@@ -6529,6 +6529,11 @@ dedent_string(VALUE string, int width) break; } } + if (!i) return 0; + rb_str_modify(string); + str = RSTRING_PTR(string); + if (RSTRING_LEN(string) != len) + rb_fatal("literal string changed: %+"PRIsVALUE, string); MEMMOVE(str, str + i, char, len - i); rb_str_set_len(string, len - i); return i; @@ -6585,7 +6590,6 @@ parser_dedent_string(VALUE self, VALUE input, VALUE width) StringValue(input); wid = NUM2UINT(width); - rb_str_modify(input); col = dedent_string(input, wid); return INT2NUM(col); } diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index ebdb2451a7..18e7d8f87c 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -970,6 +970,16 @@ x = __ENCODING__ assert_equal(-100, e.backtrace_locations.first.lineno, bug) end + def test_file_in_indented_heredoc + name = '[ruby-core:80987] [Bug #13540]' # long enough to be shared + assert_equal(name+"\n", eval("#{<<-"begin;"}\n#{<<-'end;'}", nil, name)) + begin; + <<~HEREDOC + #{__FILE__} + HEREDOC + end; + end + =begin def test_past_scope_variable assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}} @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-08-05" -#define RUBY_PATCHLEVEL 176 +#define RUBY_PATCHLEVEL 177 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 8 |