Skip to content

Commit 05519ad

Browse files
committed
Fix translating erl compiler errors to diagnostics on OTP 24
The compiler previously emitted just `line` and now emits `{line, column}`. The diagnostic struct accepts as position either: nil line {start_line, start_col, end_line, end_col} so we could have used the `column` to create the 4-tuple but we don't have enough information to do that correctly, we don't know where the line ends.
1 parent c05c1cf commit 05519ad

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/mix/lib/mix/compilers/erlang.ex

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,18 @@ defmodule Mix.Compilers.Erlang do
271271
defp to_diagnostics(warnings_or_errors, severity) do
272272
for {file, issues} <- warnings_or_errors,
273273
{line, module, data} <- issues do
274-
position = if is_integer(line) and line >= 1, do: line
274+
position =
275+
case line do
276+
# TODO: remove when we require OTP 24
277+
line when is_integer(line) and line >= 1 ->
278+
line
279+
280+
{line, _column} when is_integer(line) and line >= 1 ->
281+
line
282+
283+
_ ->
284+
nil
285+
end
275286

276287
%Mix.Task.Compiler.Diagnostic{
277288
file: Path.absname(file),

lib/mix/test/mix/umbrella_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ defmodule Mix.UmbrellaTest do
477477
test "reloads app in app tracer if .app changes" do
478478
in_fixture("umbrella_dep/deps/umbrella/apps", fn ->
479479
deps = [{:foo, in_umbrella: true}]
480+
480481
Mix.Project.in_project(:bar, "bar", [deps: deps], fn _ ->
481482
Mix.Task.run("compile", ["--verbose"])
482483
mtime = File.stat!("../foo/lib/foo.ex").mtime

0 commit comments

Comments
 (0)