hauleth/erlang-systemd

Error with Elixir mix dialyzer when using the library

datafoo opened this issue · 4 comments

I am trying to use the library in a Elixir project and also use Dialyxir.

As indicated in the doc, I specified :systemd.ready() as:

# Elixir
defmodule MyProject.Application do
  use Application

  def start(_type, _opts) do
    children = [
      MyProject.Repo,
      MyProjectWeb.Endpoint,
      :systemd.ready() # <- IMPORTANT - this is a function call (it returns the proper child spec)
    ]

    Supervisor.start_link(children, strategy: :one_for_one)
  end
end

However, because of that, mix dialyzer fails with error Function start/2 has no local return:

$ mix dialyzer
Compiling 1 file (.ex)
Finding suitable PLTs
Checking PLT...
[:absinthe, :absinthe_plug, :absinthe_relay, :argon2_elixir, :asn1, :backoff, :bodyguard, :comeonin, :commanded, :commanded_ecto_projections, :commanded_eventstore_adapter, :compiler, :connection, :cowboy, :cowboy_telemetry, :cowlib, :crypto, :db_connection, :decimal, :ecto, :ecto_sql, :eex, :elixir, :elixir_uuid, :enough, :eventstore, :fsm, :gen_stage, :gettext, :inets, :jason, :kernel, :libgraph, :logger, :mime, :nimble_parsec, :phoenix, :phoenix_ecto, :phoenix_html, :phoenix_pubsub, :phoenix_view, :plug, :plug_cowboy, :plug_crypto, :postgrex, :public_key, :ranch, :runtime_tools, :ssl, :stdlib, ...]
PLT is up to date!
No :ignore_warnings opt specified in mix.exs and default does not exist.

Starting Dialyzer
[
  check_plt: false,
  init_plt: '/home/me/dev/myproject/_build/dev/dialyxir_erlang-24.2_elixir-1.13.3_deps-dev.plt',
  files: ['/home/me/dev/myproject/_build/dev/lib/myproject/ebin/Elixir.MyProject.Accounts.AuthorizationPolicy.beam',
   ...],
  warnings: [:unknown]
]
Total errors: 1, Skipped: 0, Unnecessary Skips: 0
done in 0m10.63s
lib/myproject/application.ex:6:no_return
Function start/2 has no local return.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

Can you reproduce? Is it a problem with this library?

Information:

  • Elixir 1.13.3 (compiled with Erlang/OTP 24)
  • dialyxir 1.1.0
  • systemd 0.6.2
cw789 commented

I get the same Dialyzer warrning - Function start/2 has no local return..

Łukasz could it be that Dialyzer never will get happy with that function call within start/2,
as it always expect to call child_spec/1 itself on :systemd to get the child spec?

Working on that.

This seems to be still an issue. Added :systemd.start() to children in application will fail dialyzer:

$ mix dialyzer --force-check
Finding suitable PLTs
Checking PLT...
[:absinthe, :absinthe_phoenix, :absinthe_plug, :accept, :amqp, :appsignal, :appsignal_phoenix, :appsignal_plug, :attachments_app, :auth_app, :bamboo, :bamboo_smtp, :betsi_app, :bolt_sips, :brod, :cgmes, :cors_plug, :cowboy, :crontab, :csv, :decimal, :earmark, :ecto, :ecto_sql, :elasticsearch, :elixir, :elixir_uuid, :elsa, :ex2ms, :ex_aws, :ex_aws_s3, :ex_unit, :exoml, :flow, :forecast_app, :fun_with_flags, :fun_with_flags_ui, :gen_stage, :gettext, :gldpm2_app, :grax, :grid_state, :guardian, :hackney, :httpoison, :import_app, :instream, :jason, :jobs, :jobs_ui, ...]
Looking up modules in dialyxir_erlang-25.3_elixir-1.14.4_deps-dev.plt
Finding applications for dialyxir_erlang-25.3_elixir-1.14.4_deps-dev.plt
Finding modules for dialyxir_erlang-25.3_elixir-1.14.4_deps-dev.plt
Checking 7020 modules in dialyxir_erlang-25.3_elixir-1.14.4_deps-dev.plt
ignore_warnings: dialyzer.ignore-warnings

Starting Dialyzer
[
  check_plt: true,
  init_plt: '.../_build/dev/dialyxir_erlang-25.3_elixir-1.14.4_deps-dev.plt',
  files: ['.../_build/dev/lib/time_series_app/ebin/Elixir.TimeSeriesApp.Adapters.GraphQL.Enums.beam',
   
   ...],
  warnings: [:unknown]
]
Total errors: 155, Skipped: 153, Unnecessary Skips: 0
done in 0m31.2s
lib/ui_app/application.ex:9:no_return
Function start/2 has no local return.
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

Ah, the latest release is 0.6.2 from Dezember 2021. This seems not be released yet.

Can you please release this change as patched version 0.6.3?