Skip to content

Fix heredoc content and closing identifier being removed in method call arguments#90

Merged
fs0414 merged 2 commits intomainfrom
issue86-heredoc-cmd-miss-remove
Feb 1, 2026
Merged

Fix heredoc content and closing identifier being removed in method call arguments#90
fs0414 merged 2 commits intomainfrom
issue86-heredoc-cmd-miss-remove

Conversation

@fs0414
Copy link
Owner

@fs0414 fs0414 commented Feb 1, 2026

📋 Summary

Fixes a bug where heredoc content and closing identifiers were incorrectly removed when heredocs were used as method call arguments (e.g., puts(<<~HEREDOC)).

Root cause: The extract_location method in prism_bridge.rb only checked direct child nodes for closing_loc. When heredocs appear as method call arguments, they are grandchild nodes nested under ArgumentsNode, so they were not detected.

🔧 Changes

🐛 Bug Fix (lib/rfmt/prism_bridge.rb)

🧪 Tests (spec/rfmt_spec.rb)

  • Multiple heredocs as arguments: puts(<<~HEREDOC, <<~HEREDOC2)
  • Single heredoc as argument: puts(<<~HEREDOC)
  • Heredoc with method chain: foo.bar(<<~SQL)

🗂️ Changed Files

  • Core: lib/rfmt/prism_bridge.rb
  • Tests: spec/rfmt_spec.rb

🧪 Tests

How to run

bundle exec rspec spec/rfmt_spec.rb -e "Issue #86" --format documentation

Results

Verification

📦 Breaking Changes

None

Related Issue

Closes #86

@fs0414 fs0414 merged commit f1dd974 into main Feb 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Heredoc content and terminator are incorrectly removed

1 participant