Skip to content

Fix guarded wildcard case warnings

Fredrik Wieczerkowski requested to merge (removed):master into master

This branch addresses the issue #16 (closed) by considering wildcard patterns to be non-exhaustive if guarded.

Thus the following code snippet will still emit a warning (second branch exhausts all possible cases):

f x = case x of
  _ | False -> False
  _         -> True
  _         -> False

This snippet, however, will not:

f x = case x of
  _ | False -> False
  _         -> True

The implementation applies a basic heuristic to determine whether a guard is always true: It checks whether it contains True, success or otherwise. Thus the following definition will emit a warning:

f x = case x of
  _ | True -> False
  _        -> True
Edited by Fredrik Wieczerkowski

Merge request reports