Improve locations when warning for unreachable/overlapping patterns
Currently, the warnings for unreachable/overlapping patterns refer to the position of the first branch of the case expression. However, the position of the warning should refer to the relevant (i.e., the unreachable or overlapping) branch (or maybe the case expression itself in case of overlappings). Consider the following examples.
f x = case x of
_ -> False
_ -> True
For this file, the front end produces the following warning
Test.curry, line 2.3: Warning:
Pattern matches are potentially unreachable
In a case alternative:
_ -> ...
while the GHC outputs the following (better) message.
Test.hs:3:3: warning: [-Woverlapping-patterns]
Pattern match is redundant
In a case alternative: _ -> ...
|
3 | _ -> True
| ^^^^^^^^^
Similarly, the warnings for overlapping patterns should be improved as the following example shows.
g x = fcase x of
_ -> False
_ -> True
The following message gets printed.
Test.curry, line 2.3: Warning:
An fcase expression is potentially non-deterministic due to overlapping rules
While the message refers to the fcase expression, the message's location refers to its first branch. It would be better to refer to the position of the case expression itself.