-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exhaustiveness checking to account for case guards (#4467)
- Loading branch information
1 parent
d8abcf0
commit 5b9031a
Showing
4 changed files
with
54 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Fix exhaustiveness checking to account for case guards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Error found: | ||
in module [33mMain[0m | ||
at tests/purs/failing/4466.purs:15:44 - 15:67 (line 15, column 44 - line 15, column 67) | ||
|
||
A case expression could not be determined to cover all inputs. | ||
The following additional cases are required to cover all inputs: | ||
|
||
[33m{ sound: Quack }[0m | ||
[33m{ sound: Bark }[0m | ||
|
||
Alternatively, add a Partial constraint to the type of the enclosing value. | ||
|
||
while checking that type [33mPartial => t0[0m | ||
is at least as general as type [33mBoolean[0m | ||
while checking that expression [33mcase $0 of [0m | ||
[33m { sound: Moo } -> true[0m | ||
has type [33mBoolean[0m | ||
in value declaration [33manimalFunc[0m | ||
|
||
where [33mt0[0m is an unknown type | ||
|
||
See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information, | ||
or to contribute content related to this error. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- @shouldFailWith NoInstanceFound | ||
module Main where | ||
|
||
import Prelude | ||
|
||
import Data.Array as Array | ||
import Data.Maybe (Maybe(..)) | ||
|
||
data Sound = Moo | Quack | Bark | ||
|
||
type Animal = { sound :: Sound } | ||
|
||
animalFunc :: Array Animal -> Unit | ||
animalFunc animals | ||
| Just { sound } <- animals # Array.find \{ sound: Moo } -> true = unit | ||
| otherwise = unit |