Skip to content
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

Erroneous "typing violation" warning #13746

Closed
marcandre opened this issue Jul 29, 2024 · 1 comment
Closed

Erroneous "typing violation" warning #13746

marcandre opened this issue Jul 29, 2024 · 1 comment

Comments

@marcandre
Copy link
Contributor

marcandre commented Jul 29, 2024

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.17.2 (compiled with Erlang/OTP 25)

Operating system

Mac OS 14.5 (23F79)

Current behavior

The following code compiles with a false warning error:

    x = fn -> 42 end
    if is_atom(x), do: x.__live__()

We get:

    warning: expected a module (an atom) when invoking __live__/0 in expression:

        x.__live__()

    where "x" was given the type:

        # type: fun()
        # from: lib/basic_app_web/live/user_live/index.ex:9
        x = fn x -> x end

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

    typing violation found at:
    │
 10 │     if is_atom(x), do: x.__live__()
    │                          ~
    │
    └─ lib/basic_app_web/live/user_live/index.ex:10:26: BasicAppWeb.UserLive.Index.mount/3

Clearly, this code should not error, as x.__live__() will be called only if x is an atom.

This is particularly problematic as our CI is currently set with --warnings-as-errors, and we get this error when calling Phoenix.LiveViewTest.render_component/3 in our tests. Is there a workaround?

Expected behavior

Expecting no warning.

@marcandre marcandre changed the title Erroneous warning Erroneous "typing violation" warning Jul 29, 2024
@josevalim
Copy link
Member

I believe this has been fixed in LiveVIew (but maybe RC only?).

Also see #13701, #13715, #13727. :)

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

2 participants