Feature request: compiler warning when you've created a compile-time cycle

29 views
Skip to first unread message

al...@alexgleason.me

unread,
May 22, 2021, 6:35:58 PM5/22/21
to elixir-l...@googlegroups.com

I've spent 5 days untangling module deps in a huge Elixir codebase. I'm almost done, but I wish this problem didn't happen in the first place. I want the compiler to SCREAM at me if I've introduced a compile-time cyclic dependency.

In the short term, my plan is to add a stage to the CI, which requires that `mix xref graph --format cycles --label compile` returns empty. This will be good for catching cycles before they get merged, but it would be even better if people could know as soon as it happens.

Alex

Boris Kuznetsov

unread,
May 23, 2021, 2:39:19 AM5/23/21
to elixir-l...@googlegroups.com
Hi, Ulisses

Right now your application wouldn’t compile if you have cyclic dependencies and would scream at compile time.

Example:

# a.ex defmodule A do B.run() end # b.ex defmodule B do A.run() end

Compile-time error message:

Compiling 2 files (.ex)

== Compilation error in file lib/b.ex ==
** (CompileError)  deadlocked waiting on module A
    lib/b.ex:2: (module)
    (stdlib 3.14.2) erl_eval.erl:680: :erl_eval.do_apply/6

== Compilation error in file lib/a.ex ==
** (CompileError)  deadlocked waiting on module B
    lib/a.ex:2: (module)
    (stdlib 3.14.2) erl_eval.erl:680: :erl_eval.do_apply/6

Compilation failed because of a deadlock between files.
The following files depended on the following modules:

  lib/b.ex => A
  lib/a.ex => B

Ensure there are no compile-time dependencies between those files and that the modules they reference exist and are correctly named
 

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/d6c2f2b7510d787bd68d592993fa9841%40alexgleason.me.

Reply all
Reply to author
Forward
0 new messages