Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Incorrect indentation in try/rescue blocks. #408

Open
danieljaouen opened this issue Nov 19, 2017 · 0 comments
Open

Incorrect indentation in try/rescue blocks. #408

danieljaouen opened this issue Nov 19, 2017 · 0 comments

Comments

@danieljaouen
Copy link

danieljaouen commented Nov 19, 2017

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant