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

Opaque MapSet type causes Dialyzer error #8463

Closed
1player opened this issue Dec 4, 2018 · 2 comments
Closed

Opaque MapSet type causes Dialyzer error #8463

1player opened this issue Dec 4, 2018 · 2 comments

Comments

@1player
Copy link

1player commented Dec 4, 2018

Environment

  • Elixir & Erlang/OTP versions (elixir --version): Elixir 1.7.4 (compiled with Erlang/OTP 21)
  • Operating system: macOS 10.13.6

Current behavior

def public_field?(field, %MapSet{} = public_fields), do: MapSet.member?(public_fields, field)

gives Dialyzer error The call 'Elixir.MapSet':'member?'(_public_fields@1::#{'__struct__':='Elixir.MapSet', _=>_},_field@1::any()) does not have an opaque term of type 'Elixir.MapSet':t(_) as 1st argument

Expected behavior

Dialyzer not to give any error.

Similar to elixir-ecto/ecto#2693, fixed by making the type not opaque.

@1player 1player changed the title Opaque MapSet type breaks Dialyzer Opaque MapSet type causes Dialyzer error Dec 4, 2018
@michalmuskala
Copy link
Member

I would say that this is an issue or deficiency of dialyzer. There are two basic options: make the type completely opaque or make it completely public. We generally want to make it opaque, with just information that it's a struct public. This is not supported by dialyzer and making the type opaque and it's structure private is a much safer solution for us. Otherwise people might start using the internals or relying on implementation details which is explicitly not supported.

@josevalim
Copy link
Member

Closing in favor of #8480.

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

Successfully merging a pull request may close this issue.

3 participants