Skip to content

False positive when defining protocols for improper lists #14365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sabiwara opened this issue Mar 25, 2025 · 0 comments
Open

False positive when defining protocols for improper lists #14365

sabiwara opened this issue Mar 25, 2025 · 0 comments

Comments

@sabiwara
Copy link
Contributor

sabiwara commented Mar 25, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant