Idris2/tests/idris2/casetree002/DefaultCases.idr
Mathew Polzin fa06e9936b
Warn about unreachable default clauses (#1942)
* so much experimentation

* tests that show preliminary evidence the new stuff is working.

* small amount of cleanup

* more cleanup of various troubleshooting code.

* new test case added.

* only log unreachable indices if there are any.

* when traversing deeper simply skip over defaults since they have already been reviewed.

* Remove fallback clause that the changes in this PR correctly identified as unreachable.

* tidying up more.

* move some common functions to a new Core.Case.Util module.

* refer to case builder and case tree under new parent module.

* update imports to look for CaseTree in new submodule.

* update api ipkg

* remove unneeded application operators.

* remove or comment out unreachable default clauses caught by the changes in this PR.

* a bit of code documentation and renaming for clarity.

* bump previous version in CI.

* fix API usage of Util module.

* Add issue 1079 test cases.

* forgot to add new test cases file.

* remove commented-out lines by request of RefC author.

* Use a SortedSet instead of nubbing a list.

* update new case tree import.

* Update src/Core/Case/Util.idr

Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>

* remove function with nothing to offer above and beyond a differently named copy of the same code.

* replace a large tuple with a record; discover not all of the tuple's fields were needed.

* fix shadowing warning.

Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org>
2021-10-02 12:55:21 +01:00

51 lines
1.0 KiB
Idris

%default total
data MyBit = A | B
fullCoverage : MyBit -> Int
fullCoverage A = 1
fullCoverage B = 2
extraDefault : MyBit -> Int
extraDefault A = 1
extraDefault B = 2
extraDefault _ = 3
usefulDefault : MyBit -> Int
usefulDefault A = 1
usefulDefault _ = 2
earlyDefault : MyBit -> Int
earlyDefault _ = 1
earlyDefault A = 2
onlyDefault : MyBit -> Int
onlyDefault _ = 1
nestedFullCoverage : MyBit -> MyBit -> Int
nestedFullCoverage A A = 1
nestedFullCoverage A B = 2
nestedFullCoverage B A = 3
nestedFullCoverage B B = 4
nestedExtraDefault : MyBit -> MyBit -> Int
nestedExtraDefault A A = 1
nestedExtraDefault A B = 2
nestedExtraDefault B A = 3
nestedExtraDefault B B = 4
nestedExtraDefault _ _ = 5
nestedUsefulDefault : MyBit -> MyBit -> Int
nestedUsefulDefault A A = 1
nestedUsefulDefault A B = 2
nestedUsefulDefault B A = 3
nestedUsefulDefault _ _ = 4
nestedEarlyDefault : MyBit -> MyBit -> Int
nestedEarlyDefault A A = 1
nestedEarlyDefault A B = 2
nestedEarlyDefault B A = 3
nestedEarlyDefault _ _ = 4
nestedEarlyDefault B B = 5