Skip to content

inspect: incompatible value given to for-comprehension #14127

@SteffenDE

Description

@SteffenDE

Elixir and Erlang/OTP versions

1.19.0-dev

Operating system

macOS

Current behavior

When running mix test in the LiveView repo, we get the following warnings

mix test
    warning: incompatible value given to for-comprehension:

        %{field: field} = info <- Phoenix.LiveViewTest.Element.__info__(:struct)

    it has type:

        nil or list(%{default: if_set(term()), field: atom()})

    but expected a type that implements the Enumerable protocol, it must be one of:

        %Date.Range{} or %File.Stream{} or %Floki.HTMLTree{} or %GenEvent.Stream{} or %HashDict{} or
          %HashSet{} or %IO.Stream{} or %Jason.OrderedObject{} or %MapSet{} or
          %Phoenix.LiveView.LiveStream{} or %Range{} or %Stream{} or fun() or list(term()) or
          non_struct_map()

    hint: for-comprehensions use the Enumerable protocol to traverse data structures. Either convert the data type into a list (or another Enumerable) or implement the protocol accordingly

    typing violation found at:
    │
 38 │   defstruct proxy: nil,
    │   ~~~~~~~~~~~~~~~~~~~~~
    │
    └─ lib/phoenix_live_view/test/structs.ex:38: Inspect.Phoenix.LiveViewTest.Element.inspect/2

    warning: incompatible value given to for-comprehension:

        %{field: field} = info <- Phoenix.LiveViewTest.View.__info__(:struct)

    it has type:

        nil or list(%{default: if_set(term()), field: atom()})

    but expected a type that implements the Enumerable protocol, it must be one of:

        %Date.Range{} or %File.Stream{} or %Floki.HTMLTree{} or %GenEvent.Stream{} or %HashDict{} or
          %HashSet{} or %IO.Stream{} or %Jason.OrderedObject{} or %MapSet{} or
          %Phoenix.LiveView.LiveStream{} or %Range{} or %Stream{} or fun() or list(term()) or
          non_struct_map()

    hint: for-comprehensions use the Enumerable protocol to traverse data structures. Either convert the data type into a list (or another Enumerable) or implement the protocol accordingly

    typing violation found at:
    │
 17 │   defstruct id: nil,
    │   ~~~~~~~~~~~~~~~~~~
    │
    └─ lib/phoenix_live_view/test/structs.ex:17: Inspect.Phoenix.LiveViewTest.View.inspect/2

    warning: incompatible value given to for-comprehension:

        %{field: field} = info <- Phoenix.LiveViewTest.Upload.__info__(:struct)

    it has type:

        nil or list(%{default: if_set(term()), field: atom()})

    but expected a type that implements the Enumerable protocol, it must be one of:

        %Date.Range{} or %File.Stream{} or %Floki.HTMLTree{} or %GenEvent.Stream{} or %HashDict{} or
          %HashSet{} or %IO.Stream{} or %Jason.OrderedObject{} or %MapSet{} or
          %Phoenix.LiveView.LiveStream{} or %Range{} or %Stream{} or fun() or list(term()) or
          non_struct_map()

    hint: for-comprehensions use the Enumerable protocol to traverse data structures. Either convert the data type into a list (or another Enumerable) or implement the protocol accordingly

    typing violation found at:
    │
 61 │   defstruct pid: nil,
    │   ~~~~~~~~~~~~~~~~~~~
    │
    └─ lib/phoenix_live_view/test/structs.ex:61: Inspect.Phoenix.LiveViewTest.Upload.inspect/2

    warning: incompatible value given to for-comprehension:

        %{field: field} = info <- Phoenix.LiveView.UploadConfig.__info__(:struct)

    it has type:

        nil or list(%{default: if_set(term()), field: atom()})

    but expected a type that implements the Enumerable protocol, it must be one of:

        %Date.Range{} or %File.Stream{} or %Floki.HTMLTree{} or %GenEvent.Stream{} or %HashDict{} or
          %HashSet{} or %IO.Stream{} or %Jason.OrderedObject{} or %MapSet{} or
          %Phoenix.LiveView.LiveStream{} or %Range{} or %Stream{} or fun() or list(term()) or
          non_struct_map()

    hint: for-comprehensions use the Enumerable protocol to traverse data structures. Either convert the data type into a list (or another Enumerable) or implement the protocol accordingly

    typing violation found at:
    │
 83 │   defstruct name: nil,
    │   ~~~~~~~~~~~~~~~~~~~~
    │
    └─ lib/phoenix_live_view/upload_config.ex:83: Inspect.Phoenix.LiveView.UploadConfig.inspect/2

    warning: incompatible value given to for-comprehension:

        %{field: field} = info <- Phoenix.LiveView.Socket.__info__(:struct)

    it has type:

        nil or list(%{default: if_set(term()), field: atom()})

    but expected a type that implements the Enumerable protocol, it must be one of:

        %Date.Range{} or %File.Stream{} or %Floki.HTMLTree{} or %GenEvent.Stream{} or %HashDict{} or
          %HashSet{} or %IO.Stream{} or %Jason.OrderedObject{} or %MapSet{} or
          %Phoenix.LiveView.LiveStream{} or %Range{} or %Stream{} or fun() or list(term()) or
          non_struct_map()

    hint: for-comprehensions use the Enumerable protocol to traverse data structures. Either convert the data type into a list (or another Enumerable) or implement the protocol accordingly

    typing violation found at:
    │
 62 │   defstruct id: nil,
    │   ~~~~~~~~~~~~~~~~~~
    │
    └─ lib/phoenix_live_view/socket.ex:62: Inspect.Phoenix.LiveView.Socket.inspect/2

I wasn't able to create a minimal example to trigger this yet.

Expected behavior

No warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions