Deprecate map.field() syntax suggestion

@hst337 it is already deprecated when we detect it is a map at compilation time:

Interactive Elixir (1.15.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> defmodule Foo do
...(1)> def bar(map) when is_map(map) do
...(1)> map.foo()
...(1)> end
...(1)> end
warning: incompatible types:

    map() !~ atom()

in expression:

    # iex:3
    map.foo()

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

    # iex:2
    is_map(map)

where "map" was given the type atom() (due to calling var.fun()) in:

    # iex:3
    map.foo()

HINT: "var.field" (without parentheses) implies "var" is a map() while "var.fun()" (with parentheses) implies "var" is an atom()

Conflict found at
  iex:3: Foo.bar/1

We have been planning on adding a runtime deprecation for a while and there is an open issue tracking this. :slight_smile:

4 Likes