ruby-changes:64914
From: manga_osyo <ko1@a...>
Date: Sun, 17 Jan 2021 12:58:34 +0900 (JST)
Subject: [ruby-changes:64914] b84b253a69 (master): Fix Ripper with heredoc.
https://git.ruby-lang.org/ruby.git/commit/?id=b84b253a69 From b84b253a69537a14e4854e17b6d94ae75c2af050 Mon Sep 17 00:00:00 2001 From: manga_osyo <manga.osyo@g...> Date: Sun, 17 Jan 2021 04:41:01 +0900 Subject: Fix Ripper with heredoc. diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb index 35ef9b0..8222684 100644 --- a/ext/ripper/lib/ripper/lexer.rb +++ b/ext/ripper/lib/ripper/lexer.rb @@ -130,6 +130,7 @@ class Ripper https://github.com/ruby/ruby/blob/trunk/ext/ripper/lib/ripper/lexer.rb#L130 @buf = [] @stack = [] super() + @buf = @stack.pop unless @stack.empty? if raise_errors and !@errors.empty? raise SyntaxError, @errors.map(&:message).join(' ;') end diff --git a/test/ripper/test_lexer.rb b/test/ripper/test_lexer.rb index 9762478..79cb194 100644 --- a/test/ripper/test_lexer.rb +++ b/test/ripper/test_lexer.rb @@ -90,6 +90,16 @@ class TestRipper::Lexer < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ripper/test_lexer.rb#L90 assert_equal expect, Ripper.lex(src).map {|e| e[1]} end + def test_stack_at_on_heredoc_beg + src = "a <<b" + expect = %I[ + on_ident + on_sp + on_heredoc_beg + ] + assert_equal expect, Ripper.lex(src).map {|e| e[1]} + end + def test_slice assert_equal "string\#{nil}\n", Ripper.slice(%(<<HERE\nstring\#{nil}\nHERE), "heredoc_beg .*? nl $(.*?) heredoc_end", 1) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/