Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running dialiyzer with rustler 0.30.0 results in "The pattern can never match the type"" #569

Closed
neosimsim opened this issue Oct 18, 2023 · 4 comments · Fixed by #570
Closed

Comments

@neosimsim
Copy link

Running dialiyzer with rustler 0.30.0 fails with "The pattern can never match the type"

$ mix deps.get && mix dialyzer
Resolving Hex dependencies...
Resolution completed in 0.042s
Unchanged:
  dialyxir 1.4.1
  erlex 0.2.6
  jason 1.4.1
  rustler 0.30.0
  toml 0.7.0
All dependencies are up to date
Compiling 1 file (.ex)
Finding suitable PLTs
Checking PLT...
[:compiler, :eex, :elixir, :kernel, :logger, :rustler, :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/neosimsim/tmp/rustler_and_dialyzer/rustler_and_dialyzer/_build/dev/dialyxir_erlang-25.3.2.2_elixir-1.14.5_deps-dev.plt',
  files: ['/home/neosimsim/tmp/rustler_and_dialyzer/rustler_and_dialyzer/_build/dev/lib/foo/ebin/Elixir.Foo.Application.beam',
   '/home/neosimsim/tmp/rustler_and_dialyzer/rustler_and_dialyzer/_build/dev/lib/foo/ebin/Elixir.Foo.beam'],
  warnings: [:unknown]
]
Total errors: 1, Skipped: 0, Unnecessary Skips: 0
done in 0m0.91s
lib/foo.ex:1:pattern_match
The pattern can never match the type.

Pattern:
{_, {_, _}}

Type:
{0, nil}

________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

The same works with rustler 0.29.0.

Here is the an example module file that fails.

defmodule Foo do
  use Rustler,
    otp_app: :foo,
    crate: "bar",
    mode: :release,
    target_dir:
      Mix.Project.build_path()
      |> Path.join("rustler_crates")
      |> Path.expand()
end
@neosimsim
Copy link
Author

I looked at the diff between 0.29.0 and 0.30.0 and couldn't find anything strange. I wonder if this might be a bug in dialyzer?

@evnu
Copy link
Member

evnu commented Oct 20, 2023

I think this is called by this change. Dialyzer is technically right, the case will always access only one of the clauses, as this is hardcoded into the module. Note that this happens exactly once when loading the library, so this should not really be an issue. I see two options:

  1. make dialyzer ignore the problem
  2. expand the case statement during compile time

@evnu
Copy link
Member

evnu commented Oct 23, 2023

@neosimsim can you give #570 a try?

@neosimsim
Copy link
Author

@neosimsim can you give #570 a try?

That works. Thanks.

pojiro added a commit to biyooon-ex/zenohex that referenced this issue Feb 12, 2024
This issue, rusterlium/rustler#569, is already fixed by 570 but still not released.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants