Skip to content

Commit 79cec4b

Browse files
committed
Fix up ruby_parser interpolation concatenation
1 parent b2dc7e9 commit 79cec4b

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/prism/translation/ruby_parser.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,8 +905,13 @@ def visit_interpolated_x_string_node(node)
905905
results << result
906906
state = :interpolated_content
907907
end
908-
else
909-
results << result
908+
when :interpolated_content
909+
if result.is_a?(Array) && result[0] == :str && results[-1][0] == :str && (results[-1].line_max == result.line)
910+
results[-1][1] << result[1]
911+
results[-1].line_max = result.line_max
912+
else
913+
results << result
914+
end
910915
end
911916
end
912917
end

test/prism/ruby_parser_test.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,15 @@ class RubyParserTest < TestCase
2828
base = File.join(__dir__, "fixtures")
2929

3030
todos = %w[
31-
heredocs_nested.txt
3231
newline_terminated.txt
3332
regex_char_width.txt
3433
seattlerb/bug169.txt
35-
seattlerb/dstr_evstr.txt
36-
seattlerb/heredoc_squiggly_interp.txt
3734
seattlerb/masgn_colon3.txt
3835
seattlerb/messy_op_asgn_lineno.txt
3936
seattlerb/op_asgn_primary_colon_const_command_call.txt
4037
seattlerb/parse_line_evstr_after_break.txt
4138
seattlerb/regexp_esc_C_slash.txt
4239
seattlerb/str_lit_concat_bad_encodings.txt
43-
seattlerb/str_pct_nested_nested.txt
4440
unescaping.txt
4541
unparser/corpus/literal/kwbegin.txt
4642
unparser/corpus/literal/send.txt
@@ -76,12 +72,10 @@ class RubyParserTest < TestCase
7672
tilde_heredocs.txt
7773
unparser/corpus/literal/literal.txt
7874
while.txt
79-
whitequark/class_definition_in_while_cond.txt
8075
whitequark/cond_eflipflop.txt
8176
whitequark/cond_iflipflop.txt
8277
whitequark/cond_match_current_line.txt
8378
whitequark/dedenting_heredoc.txt
84-
whitequark/if_while_after_class__since_32.txt
8579
whitequark/lvar_injecting_match.txt
8680
whitequark/not.txt
8781
whitequark/numparam_ruby_bug_19025.txt

0 commit comments

Comments
 (0)