diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-05-21 11:02:59 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-05-21 18:45:16 +0000 |
| commit | b20adf90e3c195098b8a6c36cd4a048592f56366 (patch) | |
| tree | a1c582df4dd7641dff86ad9603eb2a1a203f0301 | |
| parent | 12386d36f072527cbd623aabd4df9948cf46c616 (diff) | |
[ruby/prism] Fix up ruby_parser interpolation concatenation
https://github.com/ruby/prism/commit/79cec4be22
| -rw-r--r-- | lib/prism/translation/ruby_parser.rb | 9 | ||||
| -rw-r--r-- | test/prism/ruby_parser_test.rb | 6 |
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/prism/translation/ruby_parser.rb b/lib/prism/translation/ruby_parser.rb index 43aac23be7..6e745a9041 100644 --- a/lib/prism/translation/ruby_parser.rb +++ b/lib/prism/translation/ruby_parser.rb @@ -905,8 +905,13 @@ module Prism 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 8edeac4b4f..b4afff0782 100644 --- a/test/prism/ruby_parser_test.rb +++ b/test/prism/ruby_parser_test.rb @@ -28,19 +28,15 @@ module Prism 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 @@ -76,12 +72,10 @@ module Prism 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 |
