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

Exhaustivity checking issue #562

Open
erszcz opened this issue Mar 19, 2024 · 0 comments
Open

Exhaustivity checking issue #562

erszcz opened this issue Mar 19, 2024 · 0 comments
Labels

Comments

@erszcz
Copy link
Collaborator

erszcz commented Mar 19, 2024

The following module, modelled after Gradualizer code dealing with type() instances:

-module(exhaustivity_issue).

-export([g/1]).

-include("include/gradualizer.hrl").

-type simple_type() :: {type, list | nonempty_list, [a | simple_type()]}
                     | {type, atom, {b}}.

-spec g(simple_type()) -> b | simple_type().
g({type, list, []}) ->
    b;
g({type, list, [a]}) ->
    b;
g({type, nonempty_list, []}) ->
    b;
g({type, nonempty_list, [a]}) ->
    b;
g({type, list, [a, SimpleTy]}) ->
    ?assert_type(SimpleTy, simple_type());
g({type, atom, {_InnerNode}}) ->
    b.

Fails with:

$ ./bin/gradualizer exhaustivity_issue.erl
exhaustivity_issue.erl: Nonexhaustive patterns on line 11 at column 1
Example values which are not covered:
	{type, nonempty_list, [a]}

Gradualizer commit: 81385f6

@erszcz erszcz added the bug label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant