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 #1

Open
michallepicki opened this issue Aug 6, 2022 · 2 comments
Open

Exhaustiveness checking #1

michallepicki opened this issue Aug 6, 2022 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@michallepicki
Copy link

Is there a plan to have exhaustiveness checking of case expressions?

Currently this code doesn't result in any errors:

-module(testmod).
-export([testfun/0]).

-spec testfun() -> pos_integer().
testfun() ->
  case a() of
    ok -> 1
  end.

-spec a() -> ok | number().
a() ->
  case rand:uniform(10) rem 2 of
    0 -> ok;
    1 -> 1
  end.
$ rebar3 compile
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling myapp
$ elp eqwalize-all
  Loading rebar3 build_info
  Loading applications      ████████████████████ 2/2
  Seeding database
  Compiling dependencies
NO ERRORS
@ilya-klyuchnikov
Copy link
Member

Is there a plan to have exhaustiveness checking of case expressions?

In the short term - no.
The main rationale for the current design choice: Erlang "let it crash philosophy" - for real world programs such checks may be rather noisy. - Consider implementations of gen_server - such checks would force users to add "default clauses".

We can re-consider this in future.

@ilya-klyuchnikov
Copy link
Member

It will be clarified as part of documentation soon.

@ilya-klyuchnikov ilya-klyuchnikov added the documentation Improvements or additions to documentation label Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants