Skip to content

Incorrect indentation in try/rescue blocks. #408

Open
@danieljaouen

Description

@danieljaouen

For example:

  defp compute_temperature(json) do
    try do
      temp = (json["main"]["temp"] - 273.15) |> Float.round(1)
      {:ok, temp}
      raise ArgumentError, message: "invalid argument foo"
    rescue
      error ->
        IO.puts "Error! in #{__MODULE__} #{inspect error}"
        :error
    end
  end

The final :error should have the same indentation as the IO.puts statement. However, elixir-mode indents it as follows:

  defp compute_temperature(json) do
    try do
      temp = (json["main"]["temp"] - 273.15) |> Float.round(1)
      {:ok, temp}
      raise ArgumentError, message: "invalid argument foo"
    rescue
      error ->
        IO.puts "Error! in #{__MODULE__} #{inspect error}"
      :error
    end
  end

Notice that the final :error is incorrectly indented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions