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

Exhaustiveness Checking #9

Closed
erlandsona opened this issue Oct 14, 2019 · 1 comment
Closed

Exhaustiveness Checking #9

erlandsona opened this issue Oct 14, 2019 · 1 comment

Comments

@erlandsona
Copy link

Curious about ex_type run on a little demo app I'm trying to put together for a talk I'm giving this Tuesday about opaque types in Elixir.
The repo is here
https://github.com/erlandsona/opaque
when I run mix type I get this output

❌  Controller.handle/1
   |
   | type error for Email._/1 with Email._(%Phone{_: bitstring()} | %Email{_: bitstring()} | %Address{city: bitstring(), state: %St{_: :washington | :tennessee | :oregon | :new_york | :colorado}, street: bitstring(), unit: nil | bitstring()})
   |
   | at ~/code/messin/lib/contact.ex:132

❌  Controller.handle/1
   |
   | type error for Address.format/1 with Address.format(%Phone{_: bitstring()} | %Email{_: bitstring()} | %Address{city: bitstring(), state: %St{_: :washington | :tennessee | :oregon | :new_york | :colorado}, street: bitstring(), unit: nil | bitstring()})
   |
   | at ~/code/messin/lib/contact.ex:131

What that's telling me is ex_type is not using pattern matching to allow the subset of a union type to pass down as just it's branch. Curious if exhaustiveness checking is implemented and if so, whether or not it supports this use case, why or why not?

@gyson
Copy link
Owner

gyson commented Oct 14, 2019

Thanks for reporting!

It's because ex_type did not have well support with union type + pattern match for multi-clauses function case. Some basic support (include basic exhaustiveness checking) should be added via #11 . Some advanced case would be traced at #12 .

Basic support should be able to address the case (Controller.handler/1) in this issue.

@gyson gyson closed this as completed Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants