Skip to content

Dialyzer error on with usage #13868

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

Closed
visciang opened this issue Sep 29, 2024 · 0 comments · Fixed by #13869
Closed

Dialyzer error on with usage #13868

visciang opened this issue Sep 29, 2024 · 0 comments · Fixed by #13869

Comments

@visciang
Copy link

visciang commented Sep 29, 2024

Elixir and Erlang/OTP versions

Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.17.3 (compiled with Erlang/OTP 26)

Operating system

Darwin 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:16:46 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8112 arm64

Current behavior

defmodule Dia do
  def x(arg) do
    with {:foo, :ok} <- {:foo, foo(arg)},
         {:bar, :ok} <- {:bar, bar(arg)} do
      :ok
    else
      {:foo, :error} ->
        raise ""

      {:bar, :error} ->
        :ok
    end
  end

  defp foo(x) when x >= 1, do: :ok
  defp foo(_), do: :error

  defp bar(x) when x >= 1, do: :ok
  defp bar(_), do: :error
end

Expected behavior

This is the dialyzer error reported with different version of elixir / erlang.
Could be this is an erlang issue triggered by a new implementation of the with macro in elixir 1.17.3 ?

Note: if I change the raise for ok, dialyzer is happy.

ELIXIR 1.17.3 - ERLANG 27.1

lib/dia_ok.ex:3:apply
Function application with arguments (_ :: {:foo, :error}) will never return since the 1st arguments differ
from the success typing arguments:
({:bar, :error})

ELIXIR 1.17.3 - ERLANG 26.2.5

lib/dia_ok.ex:3:apply
Function application with arguments (_ :: {:foo, :error}) will never return since the 1st arguments differ
from the success typing arguments:
({:bar, :error})

ELIXIR 1.16.3 - ERLANG 26.2.5

OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant