jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.69k stars 141 forks source link

Unknown error occurred: %FunctionClauseError{args: nil, arity: 1, clauses: nil, function: :format_long, kind: nil, module: Dialyxir.Warnings.OpaqueTypeTest} #461

Open nathanl opened 2 years ago

nathanl commented 2 years ago

Environment

Elixir 1.13.4 (compiled with Erlang/OTP 25)

More specifically, asdf versions elixir 1.13.4-otp-25 and erlang 25.0.1

Current behavior

This code:

    name
    |> :ets.whereis()
    |> is_reference()

produces

    # lib/dialyzer_ets_error.ex:7:no_return
    # Function table_exists?/1 has no local return.
    # ________________________________________________________________________________
    # Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.
    #
    # Unknown error occurred: %FunctionClauseError{args: nil, arity: 1, clauses: nil, function: :format_long, kind: nil, module: Dialyxir.Warnings.OpaqueTypeTest}
    #
    #
    # Legacy warning:
    # lib/dialyzer_ets_error.ex:9: The type test is_reference('undefined' | ets:tid()) breaks the opacity of the term 'undefined' | ets:tid()

I think this is because of

    # `-opaque tid()         :: reference().`
    # in https://github.com/erlang/otp/blob/8e62b1781a8083301aae272162946414d9af4906/lib/stdlib/src/ets.erl#L57

A minimal demo project is here

Expected behavior

It should produce a clear warning