Skip to content

Weird 'incompatible types' warning #11709

@mat-hek

Description

@mat-hek

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 24 [erts-12.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.14.0-dev (bdcf887) (compiled with Erlang/OTP 23)

Happens on Elixir 1.12.3 and 1.13.3 as well

  • Operating system: Mac OS 11.6

Current behavior

Compiling this:

defmodule A do
  def fun(state, key) do
    key0 = key
    state = %{state | key0 => true}
    key1 = key
    state = %{state | key1 => true}
    state
  end
end

gives this warning:

warning: incompatible types:

    map() !~ var2

in expression:

    # a.exs:6
    state = %{state | key1 => true}

where "state" was given the type map() in:

    # a.exs:6
    state = %{state | key1 => true}

Conflict found at
  a.exs:6: A.fun/2

Expected behavior

No warning should be reported

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions