ruby-changes:50056
From: nagachika <ko1@a...>
Date: Sat, 3 Feb 2018 11:51:05 +0900 (JST)
Subject: [ruby-changes:50056] nagachika:r62174 (ruby_2_4): merge revision(s) 60213: [Backport #14032]
nagachika 2018-02-03 11:51:00 +0900 (Sat, 03 Feb 2018) New Revision: 62174 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62174 Log: merge revision(s) 60213: [Backport #14032] parse.y: indent at '#' * parse.y (parser_here_document): update indent at '#', which is not a space. [ruby-core:83368] [Bug #14032] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/parse.y branches/ruby_2_4/test/ripper/test_lexer.rb branches/ruby_2_4/test/ruby/test_syntax.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 62173) +++ ruby_2_4/version.h (revision 62174) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" #define RUBY_RELEASE_DATE "2018-02-03" -#define RUBY_PATCHLEVEL 231 +#define RUBY_PATCHLEVEL 232 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 2 Index: ruby_2_4/parse.y =================================================================== --- ruby_2_4/parse.y (revision 62173) +++ ruby_2_4/parse.y (revision 62174) @@ -6808,6 +6808,12 @@ parser_here_document(struct parser_param https://github.com/ruby/ruby/blob/trunk/ruby_2_4/parse.y#L6808 newtok(); if (c == '#') { int t = parser_peek_variable_name(parser); + if (heredoc_line_indent != -1) { + if (heredoc_indent > heredoc_line_indent) { + heredoc_indent = heredoc_line_indent; + } + heredoc_line_indent = -1; + } if (t) return t; tokadd('#'); c = nextc(); Index: ruby_2_4/test/ruby/test_syntax.rb =================================================================== --- ruby_2_4/test/ruby/test_syntax.rb (revision 62173) +++ ruby_2_4/test/ruby/test_syntax.rb (revision 62174) @@ -659,6 +659,14 @@ e" https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_syntax.rb#L659 end end + def test_dedented_heredoc_expr_at_beginning + result = " a\n" \ + '#{1}'"\n" + expected = " a\n" \ + '#{1}'"\n" + assert_dedented_heredoc(expected, result) + end + def test_lineno_after_heredoc bug7559 = '[ruby-dev:46737]' expected, _, actual = __LINE__, <<eom, __LINE__ Index: ruby_2_4/test/ripper/test_lexer.rb =================================================================== --- ruby_2_4/test/ripper/test_lexer.rb (revision 62173) +++ ruby_2_4/test/ripper/test_lexer.rb (revision 62174) @@ -32,4 +32,24 @@ class TestRipper::Lexer < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ripper/test_lexer.rb#L32 E assert_equal(str, Ripper.tokenize(str).join(""), bug) end + + def test_expr_at_beginning_in_heredoc + src = <<~'E' + <<~B + a + #{1} + B + E + expect = %I[ + on_heredoc_beg + on_nl + on_tstring_content + on_embexpr_beg + on_int + on_embexpr_end + on_tstring_content + on_heredoc_end + ] + assert_equal expect, Ripper.lex(src).map {|e| e[1]} + end end Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 62173) +++ ruby_2_4 (revision 62174) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r60213 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/