Skip to content

Commit cb43101

Browse files
ericentinJosé Valim
authored andcommitted
Do not wait for self in parallel compiler (#5086)
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
1 parent 46cab56 commit cb43101

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

lib/elixir/lib/kernel/parallel_compiler.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,10 @@ defmodule Kernel.ParallelCompiler do
206206

207207
{:waiting, kind, child, ref, on, defining} ->
208208
# Oops, we already got it, do not put it on waiting.
209+
# OR
210+
# We're waiting on ourselves, send :found so that we can crash with a better error
209211
waiting =
210-
if :lists.any(&match?({^kind, ^on}, &1), result) do
212+
if :lists.any(&match?({^kind, ^on}, &1), result) or on in defining do
211213
send child, {ref, :found}
212214
waiting
213215
else
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defmodule Undef do
2+
def undef do
3+
%__MODULE__{}
4+
end
5+
end

lib/elixir/test/elixir/kernel/parallel_compiler_test.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ defmodule Kernel.ParallelCompilerTest do
2828
end
2929
end
3030

31+
test "emits struct undefined error when local struct is undefined" do
32+
fixtures = [fixture_path("parallel_struct/undef.ex")]
33+
assert capture_io(fn ->
34+
assert catch_exit(Kernel.ParallelCompiler.files(fixtures)) == {:shutdown, 1}
35+
end) =~ "Undef.__struct__/1 is undefined, cannot expand struct Undef"
36+
end
37+
3138
test "does not hang on missing dependencies" do
3239
fixtures = [fixture_path("parallel_compiler/bat.ex")]
3340
assert capture_io(fn ->

0 commit comments

Comments
 (0)