jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.7k stars 139 forks source link

CaseClauseError with Elixir 1.10 #387

Open datafoo opened 4 years ago

datafoo commented 4 years ago

Environment

$ elixir --version
Erlang/OTP 22 [erts-10.5.5] [source] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:1] [hipe]

Elixir 1.10.2 (compiled with Erlang/OTP 22)
$ cat mix.lock | grep dialyxir
  "dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},

Current behavior

Running mix dialyzer throws a CaseClauseError when using Elixir 1.10.

$ mix dialyzer 
Finding suitable PLTs
Checking PLT...
[:compiler, :elixir, :kernel, :logger, :stdlib]
Looking up modules in dialyxir_erlang-22.1.7_elixir-1.10.2_deps-dev.plt
Looking up modules in dialyxir_erlang-22.1.7_elixir-1.10.2.plt
Looking up modules in dialyxir_erlang-22.1.7.plt
Finding applications for dialyxir_erlang-22.1.7.plt
Finding modules for dialyxir_erlang-22.1.7.plt
Removing 192 modules from dialyxir_erlang-22.1.7.plt
** (CaseClauseError) no case clause matching: {{:nocatch, {:dialyzer_error, [78, 111, 116, 32, 97, 32, 114, 101, 103, 117, 108, 97, 114, 32, 102, 105, 108, 101, 58, 32, '/nix/store/8sazzp1p4sybxql5lv4qnz94qbaixhfg-erlang-22.1.7/lib/erlang/lib/hipe-3.19.1/ebin/erl_bif_types.beam', 10]}}, [{:dialyzer_plt, :compute_md5_from_file, 1, [file: 'dialyzer_plt.erl', line: 543]}, {:dialyzer_plt, :compute_new_md5_1, 3, [file: 'dialyzer_plt.erl', line: 509]}, {:dialyzer_plt, :check_version, 1, [file: 'dialyzer_plt.erl', line: 328]}, {:dialyzer_plt, :check_plt1, 3, [file: 'dialyzer_plt.erl', line: 477]}, {:dialyzer_plt, :"-subproc/1-fun-0-", 1, [file: 'dialyzer_plt.erl', line: 603]}]}
    dialyzer_cl.erl:250: :dialyzer_cl.check_plt/3
    dialyzer_cl.erl:183: :dialyzer_cl.plt_common/3
    dialyzer.erl:160: :dialyzer.run/1
    lib/dialyxir/plt.ex:219: Dialyxir.Plt.plt_run/1
    lib/dialyxir/plt.ex:199: Dialyxir.Plt.plt_remove/2
    lib/dialyxir/plt.ex:145: Dialyxir.Plt.check_beams/3
    lib/dialyxir/plt.ex:44: Dialyxir.Plt.check_plt/4
    (elixir 1.10.2) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3

You can reproduce with the minimal test project https://github.com/datafoo/elixir-dialyzer-issue-CaseClauseError. Note that I set my development environment with nix-shell, hence the files nixpkgs.nix, default.nix and shell.nix.

Expected behavior

Running mix dialyzer should not throw an error. When using Elixir 1.9.4, there is no errors.

asummers commented 4 years ago

This solution is nonsatisfying, but remove your PLT and PLT hash file, then rerun, and it will work.

datafoo commented 4 years ago

This solution is nonsatisfying, but remove your PLT and PLT hash file, then rerun, and it will work.

I do not have any PLT or PLT hash file in _build/dev/ so that does not work for me.

zekus commented 4 years ago

this happens often to us as well since switching to elixir 1.10

prodis commented 4 years ago

The same in my project, the error started happening with Elixir 1.10+.

smartepsh commented 4 years ago

@datafoo try $ rm ~/.mix/*.plt

lucacorti commented 4 years ago

@datafoo Also try removing the PLTs in ~/.mix/. I'm on macOS (homebrew) and I think sometimes erlang upgrades without a version change break dialyzer. Removing those fixes it for me, it is annoying though since dialyzer has to rebuild PLTs from scratch.

blakedietz commented 4 years ago

https://github.com/jeremyjh/dialyxir/issues/387#issuecomment-663688254

On macOS with Brew installed Elixir 1.10 and Erlang 23 and this seems to be the magic fix.

maennchen commented 3 years ago

I'm seeing the same error in this CI:

** (CaseClauseError) no case clause matching: {{:nocatch, {:dialyzer_error, [70, 105, 108, 101, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 58, 32, '/home/runner/work/_temp/.setup-elixir/otp/lib/hipe-4.0.1/ebin/erl_bif_types.beam', 10]}}, [{:dialyzer_plt, :compute_md5_from_file, 1, [file: 'dialyzer_plt.erl', line: 543]}, {:dialyzer_plt, :compute_new_md5_1, 3, [file: 'dialyzer_plt.erl', line: 509]}, {:dialyzer_plt, :check_version, 1, [file: 'dialyzer_plt.erl', line: 328]}, {:dialyzer_plt, :from_file1, 3, [file: 'dialyzer_plt.erl', line: 267]}, {:dialyzer_plt, :"-subproc/1-fun-0-", 1, [file: 'dialyzer_plt.erl', line: 603]}]}
    dialyzer_plt.erl:256: :dialyzer_plt.from_file/2
    dialyzer_cl.erl:371: :dialyzer_cl."-do_analysis/1-lc$^0/1-0-"/1
    dialyzer_cl.erl:371: :dialyzer_cl.do_analysis/1
    dialyzer.erl:160: :dialyzer.run/1
    (stdlib 3.14.1) timer.erl:181: :timer.tc/2
    lib/dialyxir/dialyzer.ex:47: Dialyxir.Dialyzer.Runner.run/2
    lib/dialyxir/dialyzer.ex:75: Dialyxir.Dialyzer.dialyze/3
    lib/mix/tasks/dialyzer.ex:269: Mix.Tasks.Dialyzer.run_dialyzer/2
    lib/mix/tasks/dialyzer.ex:201: Mix.Tasks.Dialyzer.run/1
    (mix 1.11.4) lib/mix/task.ex:394: Mix.Task.run_task/3
    (mix 1.11.4) lib/mix/cli.ex:84: Mix.CLI.run_task/2
    (elixir 1.11.4) lib/code.ex:931: Code.require_file/2
Error: Process completed with exit code 1.

https://github.com/jshmrtn/hygeia/runs/2389642977?check_suite_focus=true

Clearing the cache solved the issue.