User might need to add ad-hoc change to disable some matching rows, the original behavior of hobbes considers unreachable rows as an error, for example, if we have a tt.hob
foo x y = match x y with
| 0 0 -> "zero/zero"
| _ _ -> "wildcard"
| 1 _ -> "unreachable"
| _ 1 -> "unreachable"
add2 x = x + 2
bar x y = match x y with
| 1 1 -> "one/one"
| _ _ -> "wildcard"
| _ 7 -> "unreachable"
| 7 _ -> "unreachable"
Both foo and bar have 3 rows of unreachable patterns, the current behavior is
$ ./hi -s tt.hob
tt.hob:1,11-5,23: Unreachable rows in match expression:
1 .t19610 -> ['u', 'n', 'r', 'e', 'a', 'c', 'h', 'a', 'b', 'l', 'e']::[char]
.t19611 1 -> ['u', 'n', 'r', 'e', 'a', 'c', 'h', 'a', 'b', 'l', 'e']::[char]
1 foo x y = match x y with
2 | 0 0 -> "zero/zero"
3 | _ _ -> "wildcard"
4 | 1 _ -> "unreachable"
5 | _ 1 -> "unreachable"
6
7 add2 x = x + 2
8
9 bar x y = match x y with
> :l tt.hob
tt.hob:1,11-5,23: Unreachable rows in match expression:
1 .t19610 -> ['u', 'n', 'r', 'e', 'a', 'c', 'h', 'a', 'b', 'l', 'e']::[char]
.t19611 1 -> ['u', 'n', 'r', 'e', 'a', 'c', 'h', 'a', 'b', 'l', 'e']::[char]
1 foo x y = match x y with
2 | 0 0 -> "zero/zero"
3 | _ _ -> "wildcard"
4 | 1 _ -> "unreachable"
5 | _ 1 -> "unreachable"
6
7 add2 x = x + 2
8
9 bar x y = match x y with
They both stops execution and exit with error code
With newly added IgnoreUnreachableMatches language option, we can achieve something like
User might need to add ad-hoc change to disable some matching rows, the original behavior of hobbes considers unreachable rows as an error, for example, if we have a
tt.hob
Both
foo
andbar
have 3 rows of unreachable patterns, the current behavior isThey both stops execution and exit with error code
With newly added
IgnoreUnreachableMatches
language option, we can achieve something likeThe default behavior of this option is a noop. In
hi
, we can easily define a custom function and make it print related info as warningsthis->ctx
in this code is a pointer tohobbes::cc