Dialyxir complains about supervisor and significant children

When I run “mix dialyzer”, I get errors about the new “significant” and “auto_shutdown” options. What’s confusing me is that the VS Code ElixirLS extension does NOT complain about these.

Why are they different? How do I fix this?

I’m using Elixir 1.12.1, with OTP-24.0.2.

$ elixir --version
Erlang/OTP 24 [erts-12.0.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Elixir 1.12.1 (compiled with Erlang/OTP 24)

Specifically:

The function call will not succeed.

Supervisor.start_child(_sup :: pid(), %{
  :id => MyParentSupervisor,
  :restart => :temporary,
  :significant => true,
  :start => {MySupervisor, :start_link, []},
  :type => :supervisor
})

will never return since it differs in arguments with
positions 2nd from the success typing arguments:

(
  atom() | pid() | {atom(), _} | {:via, atom(), _},
  atom()
  | maybe_improper_list()
  | {atom(), _}
  | {_, _, _, _, _, _}
  | %{
      :id => _,
      :start => {atom(), atom(), [any()]},
      :modules => :dynamic | [atom()],
      :restart => :permanent | :temporary | :transient,
      :shutdown => :brutal_kill | timeout(),
      :type => :supervisor | :worker
    }
)

The specs look correct in OTP-24’s supervisor.erl.

It’s not complaining about the {:ok, {%{:strategy => :one_for_one, :auto_shutdown => :any_significant}, []}} that I’m returning from init/1.

What version of OTP was your Elixir compiled with? I remember getting similarly confused a few releases back because installing “latest Elixir” (via asdf, in my case) defaulted to a version compiled with the oldest OTP it supported…

2 Likes

I’ve edited the original post: Compiled with and running on OTP-24.

Seems that child_spec/0 in Supervisor are outdated:

child_spec() :: %{
  :id => atom() | term(),
  :start => {module(), atom(), [term()]},
  optional(:restart) => :permanent | :transient | :temporary,
  optional(:shutdown) => timeout() | :brutal_kill,
  optional(:type) => :worker | :supervisor,
  optional(:modules) => [module()] | :dynamic
}

Send a PR.

Looks like child_spec was inlined back in 2017:

For mostly documentation reasons. Has ex_doc subsequently grown any new features to help with this kind of situation (referencing a type in another module’s types)?

Closing this out. Jose rejected the PR until OTP-24 support is complete. Use :supervisor directly.

1 Like