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

Broken code when an op_asgn node contains a string with interpolation and the string contains a linefeed. #350

Closed
vidarh opened this issue Oct 13, 2023 · 4 comments

Comments

@vidarh
Copy link
Contributor

vidarh commented Oct 13, 2023

If you parse code that produces an op_asgn node, such as e.g. a statement containing "+=" or "&=" etc., and the right hand side of that contains a string, and the string contains interpolation and a linefeed, the output ends up replacing the right hand side with a "<<- HEREDOC" but never outputs the HEREDOC.

Simplest test case I've found:

y += "#{42}\n"

Test program:

require 'parser/current'
require 'unparser'

puts Unparser.unparse(Unparser.parse('y += "#{42}\n"'))

Output:

y += <<- HEREDOC
@vidarh
Copy link
Contributor Author

vidarh commented Oct 13, 2023

Found this "in the wild" when trying to parse toml-rb (lib/toml-rb/dumper.rb) which has a more complex use to test against.

@vidarh
Copy link
Contributor Author

vidarh commented Oct 13, 2023

Looking at #249 it seems likely to be a similar or the same issue.

@vidarh
Copy link
Contributor Author

vidarh commented Oct 13, 2023

Pull request: #351

@mbj
Copy link
Owner

mbj commented Oct 31, 2023

@vidarh Fix released in v0.6.10.

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

No branches or pull requests

2 participants