elixir-editors / elixir-editors/emacs-elixir

Incorrect indentation in try/rescue blocks.

Open
#408 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
454
Forks
93
PR merge metrics
No merged PRs in 30d

Description

For example:

```elixir
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:

```elixir
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.