commit 9c3c1a19eeda0fd04656254afca83e6cbc9e005a
parent 5f51e691a49f0824d26a0d0f62ac7b4b4f1e8305
Author: Sebastian <sebastian@sebsite.pw>
Date: Thu, 31 Aug 2023 02:13:47 -0400
all: make switches exhaustive
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
12 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/cmd/hare/main.ha b/cmd/hare/main.ha
@@ -91,6 +91,7 @@ export fn main() void = {
yield &test;
case "version" =>
yield &version;
+ case => abort(); // unreachable
};
task(subcmd.1);
};
diff --git a/cmd/harec/qtype.ha b/cmd/harec/qtype.ha
@@ -69,6 +69,7 @@ fn qtype_lookup(
case builtin::STR =>
return qtype_aggregate(ctx, _type);
case builtin::VOID => abort();
+ case => abort(); // TODO
};
case => abort();
};
diff --git a/cmd/haretype/main.ha b/cmd/haretype/main.ha
@@ -69,6 +69,7 @@ export fn main() void = {
case =>
fmt::fatal("Unsupported architecture");
};
+ case => abort(); // unreachable
};
};
if (len(cmd.args) == 0) {
diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha
@@ -357,6 +357,7 @@ fn line_comment(lex: *lexer) (void | error) = {
case '/' =>
r = v;
break;
+ case => abort(); // unreachable
};
};
@@ -444,6 +445,7 @@ fn lex_literal(lex: *lexer) (token | error) = {
yield "0123456789";
case strconv::base::HEX =>
yield "0123456789ABCDEFabcdef";
+ case => abort(); // unreachable
};
let suff: (size | void) = void;
diff --git a/hare/parse/decl.ha b/hare/parse/decl.ha
@@ -170,6 +170,7 @@ fn decl_func(lexer: *lex::lexer) (ast::decl_func | error) = {
yield expr(lexer)?;
case ltok::SEMICOLON =>
yield lex::unlex(lexer, tok);
+ case => abort(); // unreachable
};
return ast::decl_func {
diff --git a/hare/parse/expr.ha b/hare/parse/expr.ha
@@ -101,6 +101,7 @@ export fn expr(lexer: *lex::lexer) (ast::expr | error) = {
yield ast::binarithm_op::RSHIFT;
case ltok::TIMESEQ =>
yield ast::binarithm_op::TIMES;
+ case => abort(); // unreachable
},
object = alloc(ex),
value = alloc(expr(lexer)?),
@@ -190,6 +191,7 @@ fn alloc_expr(lexer: *lex::lexer) (ast::expr | error) = {
form = ast::alloc_form::OBJECT,
capacity = null,
};
+ case => abort(); // unreachable
};
return ast::expr {
@@ -265,6 +267,7 @@ fn measurement(lexer: *lex::lexer) (ast::expr | error) = {
yield alloc(_type(lexer)?): ast::size_expr;
case ltok::OFFSET =>
yield alloc(expr(lexer)?): ast::offset_expr;
+ case => abort(); // unreachable
};
want(lexer, ltok::RPAREN)?;
@@ -626,6 +629,7 @@ fn control(lexer: *lex::lexer) (ast::expr | error) = {
case lex::token =>
yield null: ast::return_expr;
};
+ case => abort(); // unreachable
};
return ast::expr {
start = tok.2,
@@ -925,6 +929,7 @@ fn plain_struct(
case ltok::NAME, ltok::STRUCT =>
lex::unlex(lexer, tok);
append(fields, struct_field(lexer)?);
+ case => abort(); // unreachable
};
switch (want(lexer, ltok::COMMA, ltok::RBRACE)?.0) {
@@ -933,6 +938,7 @@ fn plain_struct(
if (try(lexer, ltok::RBRACE)? is lex::token) {
break;
};
+ case => abort(); // unreachable
};
};
@@ -1115,6 +1121,7 @@ fn switch_expr(lexer: *lex::lexer) (ast::expr | error) = {
if (try(lexer, ltok::ARROW)? is lex::token) {
break;
};
+ case => abort(); // unreachable
};
};
diff --git a/hare/parse/type.ha b/hare/parse/type.ha
@@ -407,6 +407,7 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = {
case ltok::RUNE =>
want(lexer, ltok::LBRACE)?;
yield builtin_type::RUNE;
+ case => abort(); // unreachable
};
};
diff --git a/hare/types/hash.ha b/hare/types/hash.ha
@@ -59,6 +59,8 @@ fn builtin_storage(b: builtin) u8 = {
return storage::VALIST;
case builtin::VOID =>
return storage::VOID;
+ case builtin::FCONST, builtin::ICONST, builtin::RCONST =>
+ abort(); // unreachable
};
};
diff --git a/hare/unit/process.ha b/hare/unit/process.ha
@@ -283,6 +283,7 @@ fn process_constant(ctx: *context, aexpr: *ast::expr) (*expr | error) = {
yield ast::builtin_type::F32;
case lex::ltok::LIT_F64, lex::ltok::LIT_FCONST =>
yield ast::builtin_type::F64;
+ case => abort(); // unreachable
}),
v.value: constant,
);
diff --git a/hare/unparse/expr.ha b/hare/unparse/expr.ha
@@ -167,6 +167,10 @@ export fn expr(
yield "^=";
case binarithm_op::LXOR =>
yield "^^=";
+ case binarithm_op::GT, binarithm_op::GTEQ,
+ binarithm_op::LESS, binarithm_op::LESSEQ,
+ binarithm_op::LEQUAL, binarithm_op::NEQUAL =>
+ abort(); // unreachable
};
};
z += fmt::fprintf(out, " {} ", op)?;
diff --git a/unix/signal/+freebsd.ha b/unix/signal/+freebsd.ha
@@ -388,6 +388,5 @@ export fn signame(sig: sig) const str = {
return "SIGTHR";
case sig::LIBRT =>
return "SIGLIBRT";
- case => abort(); // unreachable
};
};
diff --git a/unix/signal/+linux.ha b/unix/signal/+linux.ha
@@ -94,7 +94,6 @@ export fn resetall() void = {
reset(sig::VTALRM);
reset(sig::PROF);
reset(sig::WINCH);
- reset(sig::IO);
reset(sig::POLL);
reset(sig::PWR);
reset(sig::SYS);
@@ -320,7 +319,7 @@ export type sig = enum int {
VTALRM = rt::SIGVTALRM, // Virtual timer expired.
PROF = rt::SIGPROF, // Profiling timer expired.
WINCH = rt::SIGWINCH, // Window resize signal.
- IO = rt::SIGIO, // I/O now possible.
+ IO = rt::SIGIO, // I/O now possible (synonymous with sig::POLL).
POLL = rt::SIGPOLL, // Pollable event.
PWR = rt::SIGPWR, // Power failure.
SYS = rt::SIGSYS, // Bad system call.
@@ -424,14 +423,11 @@ export fn signame(sig: sig) const str = {
return "SIGPROF";
case sig::WINCH =>
return "SIGWINCH";
- case sig::IO =>
- return "SIGIO";
case sig::POLL =>
return "SIGPOLL";
case sig::PWR =>
return "SIGPWR";
case sig::SYS =>
return "SIGSYS";
- case => abort(); // unreachable
};
};