Warning in `with` clause after 1.5.0

Compiling the code below in 1.5.0 will show the warning message “this clause cannot match because of different types/sizes”, but not in 1.4.5. Is this a regression or an expected change in the compiler behaviour?

fun = fn ->
  :rand.seed(:exs64)
  if(:rand.uniform > 0.5, do: :ok, else: {:error, :fail})
end

with {:step1, :ok} <- {:step1, fun.()},
     {:step2, :ok} <- {:step2, fun.()} do
  :ok
else
  {:step1, {:error, reason}} -> {:error, reason}
  {:step2, {:error, reason}} -> {:error, reason}
end

Edit:

~ ❯❯❯ elixirc with.ex
warning: this clause cannot match because of different types/sizes
  with.ex:10

warning: this clause cannot match because of different types/sizes
  with.ex:11

This is a known issue, already fixed and scheduled for next patch release https://github.com/elixir-lang/elixir/issues/6380

1 Like