Skip to content

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

@vidarh

Description

@vidarh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions