-
Notifications
You must be signed in to change notification settings - Fork 26
Description
The error in #160 made me suspect that type_check might introduce compile-time dependencies just about everywhere.
To double check this:
# empty_mix/example.ex
defmodule EmptyMix.Example do
use TypeCheck, enable_runtime_checks: Mix.env() != :prod
@type! t :: :ok
end
# empty_mix.ex
defmodule EmptyMix do
defstruct [:name]
use TypeCheck, enable_runtime_checks: Mix.env() != :prod
@spec! hello(%{String.t() => any}) :: EmptyMix.Example.t()
def hello(_struct), do: :ok
endThis compiles, but also introduces a compile-time dependency that should not be there:
$ mix xref graph
lib/empty_mix.ex
└── lib/empty_mix/example.ex (compile)
lib/empty_mix/example.ex
I understand that type_check needs to generate code at compile time to check that inputs and outputs corresponds to the specified specs, but hopefully there's way for that generation to not rely on the actual spec in EmptyMix.Example and only generate calls to that module. This would only introduce a runtime dependency on Example and not a compile-time one.
Compile-time dependencies can easily lead to many transitive dependencies and make it necessary to recompile most of a project whenever just about anything changes (see e.g. https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects)