Skip to content

Guard clauses in "with" cause Dialyzer warnings (in Elixir 1.5) #6426

@Cohedrin

Description

@Cohedrin

Environment

  • elixir 1.5.1
  • OTP 20.0
  • Operating system: OSX

Current behavior

Adding a guard clause inside of an else block of a with statement causes dialyzer to raise an warning

Example:

  def with_else do
    with :ok <- ok_or_error(),
         :ok <- ok_or_other_error(),
         :ok <- ok_or_tuple_error(),
         :ok <- ok_or_tuple_list_error() do
      :ok
    else
      :error ->
        :error
      :other_error ->
        :other_error
      {:error, msg} when is_list(msg) ->
        :error
      {:error, _msg} ->
        :error
    end
  end

Will raise a warning Guard test is_list(msg@1::'err') can never succeed

Expected behavior

No warning is raised, this was the behavior on 1.4.x

I've added a failing test case here for this issue.

Notes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions