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

Bug in formatter with concatenated heredocs when assigned to attributes #10863

Closed
eksperimental opened this issue Apr 1, 2021 · 1 comment
Closed

Comments

@eksperimental
Copy link
Contributor

Environment

  • Elixir & Erlang/OTP versions (elixir --version): Elixir 1.13.0-dev (37a09fe)

Current behavior

given the code

defmodule Debug.ConcatenateHeredocs do
  @foo "Two"

  @moduledoc ~S"""
    One
    """ <>
      ~s"""
      #{@foo}
      """ <>
      ~S"""
      Three
      """

  def foo() do
    moduledoc =
      ~S"""
      One
      """ <>
        ~s"""
        #{@foo}
        """ <>
        ~S"""
        Three
        """
  end
end

mix format will wrongly indent the concatenated heredocs that are assigned to a the @moduledoc attribute

defmodule Debug.ConcatenateHeredocs do
  @foo "Two"

  @moduledoc ~S"""
             One
             """ <>
               ~s"""
               #{@foo}
               """ <>
               ~S"""
               Three
               """

  def foo() do
    moduledoc =
      ~S"""
      One
      """ <>
        ~s"""
        #{@foo}
        """ <>
        ~S"""
        Three
        """
  end
end

Expected behavior

Indent the attribute value as it does with the variable.

  @moduledoc ~S"""
    One
    """ <>
      ~s"""
      #{@foo}
      """ <>
      ~S"""
      Three
      """
@eksperimental eksperimental changed the title Bug in formatter with concatenated heredocs when assigning attributes Bug in formatter with concatenated heredocs when assigned to attributes Apr 1, 2021
@josevalim
Copy link
Member

The current behavior is correct. The nice wrapping only happens in few circumstances (heredoxs, fn...). An operator is not one of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants