diff --git a/lib/parser/lexer/literal.rb b/lib/parser/lexer/literal.rb index ea32d750e..537d32ea0 100644 --- a/lib/parser/lexer/literal.rb +++ b/lib/parser/lexer/literal.rb @@ -6,6 +6,7 @@ module Parser class Lexer::Literal DELIMITERS = { '(' => ')', '[' => ']', '{' => '}', '<' => '>' } SPACE = ' '.ord + TAB = "\t".ord TYPES = { # type start token interpolate? @@ -247,7 +248,7 @@ def delimiter?(delimiter) # E # because there are not enough leading spaces in the closing delimiter. delimiter.end_with?(@end_delim) && - delimiter.sub(/#{Regexp.escape(@end_delim)}\z/, '').bytes.all? { |c| c == SPACE } + delimiter.sub(/#{Regexp.escape(@end_delim)}\z/, '').bytes.all? { |c| c == SPACE || c == TAB } elsif @indent @end_delim == delimiter.lstrip else diff --git a/test/test_parser.rb b/test/test_parser.rb index 79245fa79..f76eadb38 100644 --- a/test/test_parser.rb +++ b/test/test_parser.rb @@ -11488,4 +11488,12 @@ def test_anonymous_params_in_nested_scopes 'def b(**) ->(**) {c()} end', SINCE_3_3) end + + def test_parser_bug_989 + assert_parses( + s(:str, "\t\tcontent\n"), + "\t<<-HERE\n\t\tcontent\n\tHERE", + %q{}, + ALL_VERSIONS) + end end diff --git a/test/test_runner_rewrite.rb b/test/test_runner_rewrite.rb index 4a7676628..42c707d9f 100644 --- a/test/test_runner_rewrite.rb +++ b/test/test_runner_rewrite.rb @@ -10,11 +10,11 @@ class TestRunnerRewrite < Minitest::Test def assert_rewriter_output(path, args, input: 'input.rb', output: 'output.rb', expected_output: '', expected_error: '') - @ruby_rewrite = BASE_DIR.expand_path + '../bin/ruby-rewrite' - @test_dir = BASE_DIR + path + @ruby_rewrite = ::BASE_DIR.expand_path + '../bin/ruby-rewrite' + @test_dir = ::BASE_DIR + path @fixtures_dir = @test_dir + 'fixtures' - Dir.mktmpdir("parser", BASE_DIR.expand_path.to_s) do |tmp_dir| + Dir.mktmpdir("parser", ::BASE_DIR.expand_path.to_s) do |tmp_dir| tmp_dir = Pathname.new(tmp_dir) sample_file = tmp_dir + "#{path}.rb" sample_file_expanded = sample_file.expand_path