diff --git a/lib/rdoc/parser/ripper_state_lex.rb b/lib/rdoc/parser/ripper_state_lex.rb index 773a830450..3c761f985d 100644 --- a/lib/rdoc/parser/ripper_state_lex.rb +++ b/lib/rdoc/parser/ripper_state_lex.rb @@ -555,6 +555,10 @@ def get_squashed_tk tk[:text] += tk_ahead[:text] tk[:kind] = tk_ahead[:kind] tk[:state] = tk_ahead[:state] + when :on_heredoc_beg, :on_tstring, :on_dstring # frozen/non-frozen string literal + tk[:text] += tk_ahead[:text] + tk[:kind] = tk_ahead[:kind] + tk[:state] = tk_ahead[:state] else @buf.unshift tk_ahead end diff --git a/test/test_rdoc_parser_ruby.rb b/test/test_rdoc_parser_ruby.rb index 8e31141f59..6f7413a0b4 100644 --- a/test/test_rdoc_parser_ruby.rb +++ b/test/test_rdoc_parser_ruby.rb @@ -2848,6 +2848,35 @@ def blah() assert_equal expected, markup_code end + def test_parse_mutable_heredocbeg + @filename = 'file.rb' + util_parser <def blah() + @str = -<<-EOM + EOM + end +EXPECTED + expected = expected.rstrip + + @parser.scan + + foo = @top_level.classes.first + assert_equal 'Foo', foo.full_name + + blah = foo.method_list.first + markup_code = blah.markup_code.sub(/^.*\n/, '') + assert_equal expected, markup_code + end + def test_parse_statements_method_oneliner_with_regexp util_parser <