From 697d346520c03c2363139e89a5752bbbfbb6f52a Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Tue, 21 May 2024 11:02:59 -0400 Subject: [PATCH] Fix up ruby_parser interpolation concatenation --- lib/prism/translation/ruby_parser.rb | 9 +++++++-- test/prism/ruby_parser_test.rb | 9 --------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/prism/translation/ruby_parser.rb b/lib/prism/translation/ruby_parser.rb index 43aac23be7b..6e745a9041b 100644 --- a/lib/prism/translation/ruby_parser.rb +++ b/lib/prism/translation/ruby_parser.rb @@ -905,8 +905,13 @@ def visit_interpolated_x_string_node(node) results << result state = :interpolated_content end - else - results << result + when :interpolated_content + if result.is_a?(Array) && result[0] == :str && results[-1][0] == :str && (results[-1].line_max == result.line) + results[-1][1] << result[1] + results[-1].line_max = result.line_max + else + results << result + end end end end diff --git a/test/prism/ruby_parser_test.rb b/test/prism/ruby_parser_test.rb index 8edeac4b4f8..646a95cd040 100644 --- a/test/prism/ruby_parser_test.rb +++ b/test/prism/ruby_parser_test.rb @@ -28,19 +28,15 @@ class RubyParserTest < TestCase base = File.join(__dir__, "fixtures") todos = %w[ - heredocs_nested.txt newline_terminated.txt regex_char_width.txt seattlerb/bug169.txt - seattlerb/dstr_evstr.txt - seattlerb/heredoc_squiggly_interp.txt seattlerb/masgn_colon3.txt seattlerb/messy_op_asgn_lineno.txt seattlerb/op_asgn_primary_colon_const_command_call.txt seattlerb/parse_line_evstr_after_break.txt seattlerb/regexp_esc_C_slash.txt seattlerb/str_lit_concat_bad_encodings.txt - seattlerb/str_pct_nested_nested.txt unescaping.txt unparser/corpus/literal/kwbegin.txt unparser/corpus/literal/send.txt @@ -68,20 +64,15 @@ class RubyParserTest < TestCase seattlerb/heredoc_bad_hex_escape.txt seattlerb/heredoc_bad_oct_escape.txt seattlerb/heredoc_with_extra_carriage_horrible_mix.txt - seattlerb/heredoc_with_extra_carriage_returns_windows.txt - seattlerb/heredoc_with_only_carriage_returns_windows.txt - seattlerb/heredoc_with_only_carriage_returns.txt spanning_heredoc_newlines.txt spanning_heredoc.txt tilde_heredocs.txt unparser/corpus/literal/literal.txt while.txt - whitequark/class_definition_in_while_cond.txt whitequark/cond_eflipflop.txt whitequark/cond_iflipflop.txt whitequark/cond_match_current_line.txt whitequark/dedenting_heredoc.txt - whitequark/if_while_after_class__since_32.txt whitequark/lvar_injecting_match.txt whitequark/not.txt whitequark/numparam_ruby_bug_19025.txt