Skip to content

Commit

Permalink
Fix up ruby_parser interpolation concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed May 21, 2024
1 parent b2dc7e9 commit 697d346
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
9 changes: 7 additions & 2 deletions lib/prism/translation/ruby_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions test/prism/ruby_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 697d346

Please sign in to comment.