Skip to content

Exhaustivity checking issue #562

@erszcz

Description

@erszcz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions