Skip to content
This repository was archived by the owner on Aug 15, 2018. It is now read-only.
This repository was archived by the owner on Aug 15, 2018. It is now read-only.

check clause heads for exhaustion #13

@mndrix

Description

@mndrix

Consider this code:

:- type thing ---> foo; bar(integer).

%% something(X:thing) is det.
something(foo).

There's some obvious disagreement here. The modeline says that the predicate is deterministic (won't ever fail). However, there is no clause for the bar(integer) case. This is almost certainly a bug.

For each predicate that has a type signature and mode of det or multi, generate random values (using quickcheck:arbitrary/2) for each argument and make sure at least one clause matches. If we find a value for which there are no matching clauses, generate a warning.

Be careful that this doesn't generate false warnings. Prolog often omits cases specifically to generate failure. That's why I suggest that this check must consider the predicate's mode.

Of course, this check should work for types other than algebraic data types. Any type for which we can generate random values should be checkable by this approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions