diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-05-23 12:40:21 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-05-23 12:40:21 -0400 |
| commit | fba2b99b65d5023675a3f270adbc87ef0b0ede8f (patch) | |
| tree | c1af45c5b80c9813a48fcc25386f331786004c73 /typecheck.c | |
| parent | 7a741e65e663d9ce9013691d2479c6fdba4b798b (diff) | |
Support 'while when'
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/typecheck.c b/typecheck.c index 217937ed..9964c9d9 100644 --- a/typecheck.c +++ b/typecheck.c @@ -948,7 +948,9 @@ type_t *get_type(env_t *env, ast_t *ast) break; } } - if (!any_unhandled) + // HACK: `while when ...` is handled by the parser adding an implicit + // `else: stop`, which has an empty source code span. + if (!any_unhandled && when->else_body->end > when->else_body->start) code_err(when->else_body, "This 'else' block will never run because every tag is handled"); type_t *else_t = get_type(env, when->else_body); |
