hrzndhrn / recode

A linter with autocorrection and a refactoring tool.
MIT License
283 stars 15 forks source link

Strange error on heredoc #17

Closed lud closed 1 year ago

lud commented 2 years ago

This code

  def hello do
    """
    world
    """
    |> String.split()
  end

gets rewritten as:

  def hello do
    "world
"
    |> nil
    |> String.split()
  end
NickNeck commented 2 years ago

That is really strange. I assume that is caused by Recode.Task.SinglePipe. Would you expect that this will be rewritten to:

def hello do
  String.split("""
  world
  """)
end
lud commented 2 years ago

Yes, I guess that somehow recode or sourceror detects a call in the AST that defines a multiline string, hence the nil.