Skip to content

OTP-28.0-rc.1: invalid opacity warning with dialyzer #9427

Open
@RoadRunnr

Description

Describe the bug

This test module:

-module(t2a).

-compile([export_all, nowarn_export_all]).

test(L) when is_map(L) ->
    maps:map(fun check/2, L).

check(atom, V) when is_atom(V) -> V;
check(list, V) when is_list(V) -> V;
check(map, V) ->
    case is_map(V) of
        true ->
            lists:foreach(fun(_) -> ok end, maps:to_list(V)),
            V;
        _ ->
            erlang:error(badarg, [set, V])
    end;
check(K, V) ->
    erlang:error(badarg, [K, V]).

Result in dialyzer warning that are IMHO invalid:

t2a.erl:8:1: Body yields the type 
          atom() which violates the opacity of the other clauses.
t2a.erl:9:1: Body yields the type 
          maybe_improper_list() which violates the opacity of the other clauses.
t2a.erl:10:1: Body yields the type 
          map() | maps:iterator(_, _) which violates the opacity of the other clauses.
 done in 0m0.22s
done (warnings were emitted)

To Reproduce

  • save to t2a.erl
  • compile with debug and run dialyzer on it: erlc +debug_info t2a.erl; dialyzer t2a.beam

Expected behavior
No warning should be produced by dialyzer

Affected versions
OTP-28.0-rc1

Activity

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

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions