Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unparser failing to round-trip dynamic heredoc + block #311

Closed
dgollahon opened this issue Apr 14, 2022 · 1 comment · Fixed by #312
Closed

Unparser failing to round-trip dynamic heredoc + block #311

dgollahon opened this issue Apr 14, 2022 · 1 comment · Fixed by #312
Assignees
Labels

Comments

@dgollahon
Copy link
Sponsor Collaborator

test.rb (slightly minified version of actual code i wrote):

notify(
  <<~MSG
    #{1}
  MSG
) do |report|
  report.something
end
parsed = Unparser.parse(File.read('test.rb')) # works fine

# but it fails the round-trip:
Unparser.unparse_validate(parsed) # => #<Unparser::Either::Left value=#<Unparser::Validation generated_node=#<Unparser::Either::Left value=nil> generated_source=#<Unparser::Either::Left value=nil> identification="(string)" original_node=#<Unparser::Either::Left value=#<Parser::SyntaxError: unterminated string meets end of file>> original_source=#<Unparser::Either::Right value="notify(<<-HEREDOC) {\n\#{1}\nHEREDOC |report|\n  report.something\n}">>>

unparsed output:

notify(<<-HEREDOC) {
#{1}
HEREDOC |report|
  report.something
}
@mbj
Copy link
Owner

mbj commented Apr 14, 2022

heredocs and the AST around them are the bane of unparser. I need to talk to the parser authors to make the AST more uniform else this is wack a mole.

@mbj mbj self-assigned this Apr 18, 2022
@mbj mbj added the bug label Apr 18, 2022
mbj added a commit that referenced this issue Apr 18, 2022
mbj added a commit that referenced this issue Apr 18, 2022
mbj added a commit that referenced this issue Apr 18, 2022
@mbj mbj closed this as completed in #312 Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants