Skip to content

False positive when defining protocols for improper lists #14365

Closed
@sabiwara

Description

@sabiwara

Elixir and Erlang/OTP versions

main

Operating system

MacOs

Current behavior

From phoenix_html

warning: incompatible types given to Phoenix.HTML.Safe.to_iodata/1:

        Phoenix.HTML.Safe.to_iodata([60, "foo" | 62])

    given types:

        non_empty_list(binary() or integer(), integer())

    but expected a type that implements the Phoenix.HTML.Safe protocol, it must be one of:

        dynamic(%Date{} or %DateTime{} or %NaiveDateTime{} or %Time{} or %URI{}) or atom() or binary() or
          float() or integer() or list(term()) or {...}

    typing violation found at:
13assert Safe.to_iodata([?<, "foo" | ?>]) == ["&lt;", "foo" | "&gt;"]

Expected behavior

We should probably consider implementing the List protocol as a maybe_improper_list.

I have a tentative fix, will open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions