-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make cosmetic improvements to nonexhaustive diagnostics
Consider the following program: datatype a = A1 of int * int | A2 of int | A3 of int | A4 of int * int | A5 of int | A6 of int datatype b = B1 of a | B2 of a * a fun f1 b = case b of B1 (A1 (x,_) | A2 x) => x + 1 | B2 (A3 y, A5 z) => y + z fun f2 b = case b of B1 _ => true fun f3 b = case b of (A3 y, A5 z) => y + z Previously, the following error messages were generated: Warning: w.sml 6.3. Case is not exhaustive. missing pattern: (B2 ((A1 _) | (A2 _) | (A4 _) | (A5 _) | (A6 _), _)) | (B2 ((A3 _), (A1 _) | (A2 _) | (A3 _) | (A4 _) | (A6 _))) | (B1 (A3 _) | (A4 _) | (A5 _) | (A6 _)) in: case b of (B1 (A1 (x, _) |A2 x)) ... y, A5 z)) => (y + z) Warning: w.sml 9.3. Case is not exhaustive. missing pattern: (B2 _) in: case b of (B1 _) => true Warning: w.sml 12.3. Case is not exhaustive. missing pattern: ((A1 _) | (A2 _) | (A4 _) | (A5 _) | (A6 _), _) | ((A3 _), (A1 _) | (A2 _) | (A3 _) | (A4 _) | (A6 _)) in: case b of (A3 y, A5 z) => (y + z) In the first warning, there are insufficient parens for the or-pattern argument to the B1 constructor and extraneous parens around some of the AX constructors. It is also curious that the B2 constructor patterns are given before the B1 constructor patterns. In the second warning, there are extraneous parens around the B1 _ pattern. Now, the following error messages are generated: Warning: w.sml 6.3. Case is not exhaustive. missing pattern: (B1 (A3 _ | A4 _ | A5 _ | A6 _) | B2 (A3 _, (A1 _ | A2 _ | A3 _ | A4 _ | A6 _)) | B2 ((A1 _ | A2 _ | A4 _ | A5 _ | A6 _), _)) in: case b of B1 (A1 (x, _) | A2 x) = ... y, A5 z) => (y + z) Warning: w.sml 9.3. Case is not exhaustive. missing pattern: B2 _ in: case b of B1 _ => true Warning: w.sml 12.3. Case is not exhaustive. missing pattern: ((A3 _, (A1 _ | A2 _ | A3 _ | A4 _ | A6 _)) | ((A1 _ | A2 _ | A4 _ | A5 _ | A6 _), _)) in: case b of (A3 y, A5 z) => (y + z) The missing pattern examples are now pretty-printed in the same manner as other patterns.
- Loading branch information
1 parent
0cdc1f1
commit bf6153c
Showing
4 changed files
with
70 additions
and
44 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
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
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