summaryrefslogtreecommitdiff
path: root/src/pattern_completeness.mli
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-01-25 19:05:39 +0000
committerAlasdair Armstrong2018-01-25 19:08:27 +0000
commitb7e388f0193a89608687760f50e476c059f0f49c (patch)
tree8de862216287fd9b5b7a2cd9256b11fd3688bee4 /src/pattern_completeness.mli
parent2ee59d0eee7508ebe4e84b4cf2468d8631b2c418 (diff)
Add pattern completness check for match statements
Gives warnings when pattern matches are incomplete, when matches are redundant (in certain cases), or when no unguarded patterns exist. For example the following file: enum Test = {A, C, D} val test1 : Test -> string function test1 x = match x { A => "match A", B => "this will match anything, because B is unbound!", C => "match C", D => "match D" } val test2 : Test -> string function test2 x = match x { A => "match A", C => "match C" /* No match for D */ } val test3 : Test -> string function test3 x = match x { A if false => "never match A", C => "match C", D => "match D" } val test4 : Test -> string function test4 x = match x { A if true => "match A", C if true => "match C", D if true => "match D" } will produce the following warnings Warning: Possible redundant pattern match at file "test.sail", line 10, character 5 to line 10, character 5 C => "match C", Warning: Possible redundant pattern match at file "test.sail", line 11, character 5 to line 11, character 5 D => "match D" Warning: Possible incomplete pattern match at file "test.sail", line 17, character 3 to line 17, character 7 match x { Most general matched pattern is A_|C_ Warning: Possible incomplete pattern match at file "test.sail", line 26, character 3 to line 26, character 7 match x { Most general matched pattern is C_|D_ Warning: No non-guarded patterns at file "test.sail", line 35, character 3 to line 35, character 7 match x { warnings can be turned of with the -no_warn flag.
Diffstat (limited to 'src/pattern_completeness.mli')
0 files changed, 0 insertions, 0 deletions