hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit abf25291435bcf240a753be2ee0ed987c4877329
parent 63de96e1d4799150342348ceb252dbef21b481a1
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Wed, 28 Apr 2021 15:25:25 -0400

Revert match syntax changes

Signed-off-by: Eyal Sawady <ecs@d2evs.net>

Diffstat:
Mascii/strcmp.ha | 16++++++++--------
Mbufio/buffered.ha | 4++--
Mbufio/scanner.ha | 10+++++-----
Mbytes/tokenize.ha | 26+++++++++++++-------------
Mcmd/hare/plan.ha | 4++--
Mcmd/hare/schedule.ha | 2+-
Mcmd/hare/subcmds.ha | 18+++++++++---------
Mcmd/haredoc/docstr.ha | 26+++++++++++++-------------
Mcmd/haredoc/errors.ha | 4++--
Mcmd/haredoc/hare.ha | 2+-
Mcmd/haredoc/html.ha | 28++++++++++++++--------------
Mcmd/haredoc/main.ha | 2+-
Mcmd/haredoc/resolver.ha | 4++--
Mcompress/flate/inflate.ha | 16++++++++--------
Mcompress/zlib/reader.ha | 8++++----
Mcrypto/random/random.ha | 2+-
Mdirs/xdg.ha | 2+-
Mencoding/hex/hex.ha | 2+-
Mencoding/utf8/decode.ha | 12++++++------
Merrors/string.ha | 14+++++++-------
Mfmt/fmt.ha | 22+++++++++++-----------
Mformat/html/escape.ha | 2+-
Mformat/xml/+test.ha | 4++--
Mformat/xml/parser.ha | 52++++++++++++++++++++++++++--------------------------
Mformat/xml/types.ha | 4++--
Mfs/fs.ha | 10+++++-----
Mfs/mem/+test.ha | 4++--
Mfs/mem/mem.ha | 14+++++++-------
Mfs/mem/util.ha | 2+-
Mfs/util.ha | 10+++++-----
Mgetopt/getopts.ha | 16++++++++--------
Mhare/ast/expr.ha | 2+-
Mhare/ast/type.ha | 2+-
Mhare/lex/+test.ha | 2+-
Mhare/lex/lex.ha | 94++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mhare/module/context.ha | 4++--
Mhare/module/manifest.ha | 34+++++++++++++++++-----------------
Mhare/module/scan.ha | 12++++++------
Mhare/module/types.ha | 2+-
Mhare/parse/decl.ha | 24++++++++++++------------
Mhare/parse/expr.ha | 100++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mhare/parse/ident.ha | 4++--
Mhare/parse/import.ha | 4++--
Mhare/parse/type.ha | 48++++++++++++++++++++++++------------------------
Mhare/unparse/decl.ha | 2+-
Mhare/unparse/expr.ha | 10+++++-----
Mhare/unparse/type.ha | 10+++++-----
Mio/+test/copy.ha | 8++++----
Mio/+test/limit.ha | 12++++++------
Mio/copy.ha | 4++--
Mio/drain.ha | 2+-
Mio/tee.ha | 2+-
Mnet/+linux/socket.ha | 10+++++-----
Mnet/+linux/util.ha | 2+-
Mnet/ip/ip.ha | 10+++++-----
Mos/+linux/dirfdfs.ha | 16++++++++--------
Mos/+linux/environ.ha | 4++--
Mos/+linux/fdstream.ha | 2+-
Mos/+linux/fs.ha | 6+++---
Mos/exec/cmd.ha | 8++++----
Mos/exec/exec+linux.ha | 4++--
Mos/exec/types.ha | 2+-
Mpath/iter.ha | 2+-
Mpath/names.ha | 6+++---
Mrt/+linux/segmalloc.ha | 2+-
Mrt/+linux/syscalls.ha | 4++--
Mstrconv/stou.ha | 4++--
Mstrings/index.ha | 2+-
Mstrings/iter.ha | 16++++++++--------
Mstrings/sub.ha | 6+++---
Mstrings/tokenize.ha | 14+++++++-------
Mtemp/+linux.ha | 2+-
Mtime/+linux/functions.ha | 6+++---
Munix/nice+linux.ha | 2+-
Munix/passwd/group.ha | 4++--
Munix/passwd/passwd.ha | 4++--
Munix/tty/+linux/isatty.ha | 2+-
Munix/tty/+linux/open.ha | 2+-
Munix/tty/+linux/winsize.ha | 4++--
79 files changed, 435 insertions(+), 435 deletions(-)

diff --git a/ascii/strcmp.ha b/ascii/strcmp.ha @@ -8,14 +8,14 @@ export fn strcmp(a: str, b: str) (int | void) = { let a = strings::iter(a), b = strings::iter(b); for (true) { let ra = match (strings::next(&a)) { - _: void => return match (strings::next(&b)) { - _: void => 0, - _: rune => -1, + void => return match (strings::next(&b)) { + void => 0, + rune => -1, }, r: rune => r, }; let rb = match (strings::next(&b)) { - _: void => return 1, + void => return 1, r: rune => r, }; if (!isascii(ra) || !isascii(rb)) { @@ -33,14 +33,14 @@ export fn strcasecmp(a: str, b: str) (int | void) = { let a = strings::iter(a), b = strings::iter(b); for (true) { let ra = match (strings::next(&a)) { - _: void => return match (strings::next(&b)) { - _: void => 0, - _: rune => -1, + void => return match (strings::next(&b)) { + void => 0, + rune => -1, }, r: rune => r, }; let rb = match (strings::next(&b)) { - _: void => return 1, + void => return 1, r: rune => r, }; if (!isascii(ra) || !isascii(rb)) { diff --git a/bufio/buffered.ha b/bufio/buffered.ha @@ -97,7 +97,7 @@ export fn isbuffered(s: *io::stream) bool = { export fn any_isbuffered(s: *io::stream) bool = { for (!isbuffered(s)) { s = match (io::source(s)) { - _: errors::unsupported => return false, + errors::unsupported => return false, s: *io::stream => s, }; }; @@ -157,7 +157,7 @@ fn buffered_read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = { if (n > s.ravail) { let z = match (io::read(s.source, s.rbuffer[s.ravail..])) { err: io::error => return err, - _: io::EOF => { + io::EOF => { if (s.ravail == 0) { return io::EOF; }; diff --git a/bufio/scanner.ha b/bufio/scanner.ha @@ -27,7 +27,7 @@ export fn scantok(stream: *io::stream, delim: u8) ([]u8 | io::EOF | io::error) = }; append(buf, res); }, - _: io::EOF => { + io::EOF => { if (len(buf) == 0) { return io::EOF; }; @@ -49,7 +49,7 @@ export fn scanrune(stream: *io::stream) (rune | utf8::invalid | io::EOF | io::er let b: [4]u8 = [0...]; match (io::read(stream, b[..1])?) { n: size => assert(n == 1), - _: io::EOF => return io::EOF, + io::EOF => return io::EOF, }; const sz = utf8::utf8sz(b[0]); @@ -69,8 +69,8 @@ export fn scanrune(stream: *io::stream) (rune | utf8::invalid | io::EOF | io::er let dec = utf8::decode(b[..sz]); return match (utf8::next(&dec)) { r: rune => r, - _: utf8::invalid => utf8::invalid, - _: (void | utf8::more) => io::EOF, + utf8::invalid => utf8::invalid, + (void | utf8::more) => io::EOF, }; }; @@ -131,7 +131,7 @@ export fn scanrune(stream: *io::stream) (rune | utf8::invalid | io::EOF | io::er match (scanrune(in)) { r: rune => assert(want is rune && want as rune == r), - _: io::EOF => assert(want is io::EOF), + io::EOF => assert(want is io::EOF), * => abort(), }; }; diff --git a/bytes/tokenize.ha b/bytes/tokenize.ha @@ -31,7 +31,7 @@ export fn next_token(s: *tokenizer) ([]u8 | void) = match (peek_token(s)) { s.p = types::SIZE_MAX; return b; }, - _: void => void, + void => void, }; // Same as next_token(), but does not advance the cursor @@ -42,7 +42,7 @@ export fn peek_token(s: *tokenizer) ([]u8 | void) = { if (s.p > len(s.s)) { s.p = match (index(s.s, s.d)) { i: size => i, - _: void => len(s.s), + void => len(s.s), }; }; return s.s[..s.p]; @@ -72,7 +72,7 @@ export fn remaining_tokens(s: *tokenizer) []u8 = { assert(equal(peek_token(&t) as []u8, peek_token(&t) as []u8)); match (next_token(&t)) { b: []u8 => assert(equal([4, 5], b)), - _: void => abort(), + void => abort(), }; assert(peek_token(&t) is void); @@ -84,19 +84,19 @@ export fn remaining_tokens(s: *tokenizer) []u8 = { assert(equal(peek_token(&t) as []u8, peek_token(&t) as []u8)); match (next_token(&t)) { b: []u8 => assert(equal([], b)), - _: void => abort(), + void => abort(), }; assert(equal(peek_token(&t) as []u8, peek_token(&t) as []u8)); match (next_token(&t)) { b: []u8 => assert(equal([1], b)), - _: void => abort(), + void => abort(), }; assert(equal(peek_token(&t) as []u8, peek_token(&t) as []u8)); match (next_token(&t)) { b: []u8 => assert(equal([], b)), - _: void => abort(), + void => abort(), }; assert(peek_token(&t) is void); @@ -107,17 +107,17 @@ export fn remaining_tokens(s: *tokenizer) []u8 = { match (next_token(&t)) { b: []u8 => assert(equal([1, 1], b)), - _: void => abort(), + void => abort(), }; match (next_token(&t)) { b: []u8 => assert(equal([1], b)), - _: void => abort(), + void => abort(), }; match (next_token(&t)) { b: []u8 => assert(equal([2], b)), - _: void => abort(), + void => abort(), }; assert(next_token(&t) is void); @@ -127,12 +127,12 @@ export fn remaining_tokens(s: *tokenizer) []u8 = { match (next_token(&t)) { b: []u8 => assert(equal([], b)), - _: void => abort(), + void => abort(), }; match (next_token(&t)) { b: []u8 => assert(equal([], b)), - _: void => abort(), + void => abort(), }; assert(peek_token(&t) is void); @@ -143,12 +143,12 @@ export fn remaining_tokens(s: *tokenizer) []u8 = { match (next_token(&t)) { b: []u8 => assert(equal([], b)), - _: void => abort(), + void => abort(), }; match (next_token(&t)) { b: []u8 => assert(equal([1], b)), - _: void => abort(), + void => abort(), }; assert(equal(remaining_tokens(&t), [2, 3, 4])); diff --git a/cmd/hare/plan.ha b/cmd/hare/plan.ha @@ -118,7 +118,7 @@ fn plan_execute(plan: *plan, verbose: bool) void = { task.cmd[0], exec::strerror(err)), err: exec::exit_status! => fmt::fatal("Error: {}: {}", task.cmd[0], exec::exitstr(err)), - _: void => void, + void => void, }; task.status = status::COMPLETE; @@ -140,7 +140,7 @@ fn update_cache(plan: *plan, mod: modcache) void = { err: module::error => fmt::fatal( "Error updating module cache: {}", module::strerror(err)), - _: void => void, + void => void, }; }; diff --git a/cmd/hare/schedule.ha b/cmd/hare/schedule.ha @@ -187,7 +187,7 @@ fn sched_hare_object( path = path::join(path, namespace[i]); }; match (os::mkdirs(path)) { - _: void => void, + void => void, err: fs::error => fmt::fatal("Error: mkdirs {}: {}", path, fs::strerror(err)), }; diff --git a/cmd/hare/subcmds.ha b/cmd/hare/subcmds.ha @@ -18,7 +18,7 @@ fn default_tags() []module::tag = { fn addtags(tags: []module::tag, in: str) ([]module::tag | void) = { let in = match (module::parsetags(in)) { - _: void => return void, + void => return void, t: []module::tag => t, }; defer free(in); @@ -32,7 +32,7 @@ fn deltags(tags: []module::tag, in: str) ([]module::tag | void) = { return []; }; let in = match (module::parsetags(in)) { - _: void => return void, + void => return void, t: []module::tag => t, }; defer free(in); @@ -88,11 +88,11 @@ fn build(args: []str) void = { 'o' => output = opt.1, 't' => abort(), // TODO 'T' => tags = match (addtags(tags, opt.1)) { - _: void => fmt::fatal("Error parsing tags"), + void => fmt::fatal("Error parsing tags"), t: []module::tag => t, }, 'X' => tags = match (deltags(tags, opt.1)) { - _: void => fmt::fatal("Error parsing tags"), + void => fmt::fatal("Error parsing tags"), t: []module::tag => t, }, * => abort(), @@ -193,11 +193,11 @@ fn run(args: []str) void = { 'l' => abort(), // TODO 't' => abort(), // TODO 'T' => tags = match (addtags(tags, opt.1)) { - _: void => fmt::fatal("Error parsing tags"), + void => fmt::fatal("Error parsing tags"), t: []module::tag => t, }, 'X' => tags = match (deltags(tags, opt.1)) { - _: void => fmt::fatal("Error parsing tags"), + void => fmt::fatal("Error parsing tags"), t: []module::tag => t, }, * => abort(), @@ -277,11 +277,11 @@ fn test(args: []str) void = { 'l' => abort(), // TODO 't' => abort(), // TODO 'T' => tags = match (addtags(tags, opt.1)) { - _: void => fmt::fatal("Error parsing tags"), + void => fmt::fatal("Error parsing tags"), t: []module::tag => t, }, 'X' => tags = match (deltags(tags, opt.1)) { - _: void => fmt::fatal("Error parsing tags"), + void => fmt::fatal("Error parsing tags"), t: []module::tag => t, }, * => abort(), @@ -343,7 +343,7 @@ fn version(args: []str) void = { fmt::println()!; match (os::getenv("HAREPATH")) { - _: void => fmt::printfln("HAREPATH\t{}", HAREPATH)!, + void => fmt::printfln("HAREPATH\t{}", HAREPATH)!, s: str => fmt::printfln("HAREPATH\t{}\t(from environment)", s)!, }; if (len(args) > 1 && args[1] == "-v") { diff --git a/cmd/haredoc/docstr.ha b/cmd/haredoc/docstr.ha @@ -35,7 +35,7 @@ fn parsedoc(in: *io::stream) parser = { fn scandoc(par: *parser) (token | void) = { const rn = match (bufio::scanrune(par.src)) { - _: io::EOF => return, + io::EOF => return, rn: rune => rn, * => abort(), }; @@ -64,8 +64,8 @@ fn scantext(par: *parser) (token | void) = { const buf = strio::dynamic(); for (true) { const rn = match (bufio::scanrune(par.src)) { - _: io::EOF => break, - _: utf8::invalid => abort("Invalid UTF-8"), + io::EOF => break, + utf8::invalid => abort("Invalid UTF-8"), err: io::error => fmt::fatal(io::strerror(err)), rn: rune => rn, }; @@ -77,7 +77,7 @@ fn scantext(par: *parser) (token | void) = { '\n' => { strio::appendrune(buf, rn)!; const rn = match (bufio::scanrune(par.src)) { - _: io::EOF => break, + io::EOF => break, * => abort(), rn: rune => rn, }; @@ -99,12 +99,12 @@ fn scantext(par: *parser) (token | void) = { fn scanref(par: *parser) (token | void) = { match (bufio::scanrune(par.src)) { - _: io::EOF => return, + io::EOF => return, rn: rune => if (rn != '[') abort(), * => abort(), }; match (bufio::scanrune(par.src)) { - _: io::EOF => return, + io::EOF => return, rn: rune => if (rn != '[') { bufio::unreadrune(par.src, rn); return strings::dup("["): text; @@ -116,7 +116,7 @@ fn scanref(par: *parser) (token | void) = { defer io::close(buf); // TODO: Handle invalid syntax here for (true) match (bufio::scanrune(par.src)) { - _: io::EOF => break, + io::EOF => break, rn: rune => switch (rn) { ']' => { bufio::scanrune(par.src) as rune; // ] @@ -133,7 +133,7 @@ fn scanref(par: *parser) (token | void) = { fn scansample(par: *parser) (token | void) = { let nws = 0z; for (true) match (bufio::scanrune(par.src)) { - _: io::EOF => return, + io::EOF => return, rn: rune => switch (rn) { ' ' => nws += 1, '\t' => nws += 8, @@ -152,7 +152,7 @@ fn scansample(par: *parser) (token | void) = { let buf = strio::dynamic(); for (cont) { const rn = match (bufio::scanrune(par.src)) { - _: io::EOF => break, + io::EOF => break, rn: rune => rn, * => abort(), }; @@ -167,7 +167,7 @@ fn scansample(par: *parser) (token | void) = { // Consume whitespace for (let i = 0z; i < nws) { match (bufio::scanrune(par.src)) { - _: io::EOF => break, + io::EOF => break, * => abort(), rn: rune => switch (rn) { ' ' => i += 1, @@ -200,14 +200,14 @@ fn scanlist(par: *parser) (token | void) = { let items: list = []; for (true) { match (bufio::scanrune(par.src)) { - _: io::EOF => break, + io::EOF => break, * => abort(), rn: rune => if (rn != '-') break, }; // XXX: multi-line list items append(items, match (bufio::scanline(par.src)) { - _: io::EOF => break, - _: io::error => abort(), + io::EOF => break, + io::error => abort(), u: []u8 => strings::fromutf8(u), }); }; diff --git a/cmd/haredoc/errors.ha b/cmd/haredoc/errors.ha @@ -10,6 +10,6 @@ fn strerror(err: error) str = match (err) { err: lex::error => lex::strerror(err), err: parse::error => parse::strerror(err), err: io::error => io::strerror(err), - _: eof => "Unexpected EOF", - _: syntaxerr => "Syntax error", + eof => "Unexpected EOF", + syntaxerr => "Syntax error", }; diff --git a/cmd/haredoc/hare.ha b/cmd/haredoc/hare.ha @@ -28,7 +28,7 @@ fn details_hare(decl: ast::decl) (void | error) = { s: str => if (len(s) != 0) { fmt::printfln("//{}", s)?; }, - _: void => break, + void => break, }; unparse_hare(os::stdout, decl)?; diff --git a/cmd/haredoc/html.ha b/cmd/haredoc/html.ha @@ -146,10 +146,10 @@ fn tocentries(decls: []ast::decl, name: str, lname: str) (void | error) = { fn tocentry(decl: ast::decl) (void | error) = { fmt::printf("{} ", match (decl.decl) { - _: ast::decl_func => "fn", - _: []ast::decl_type => "type", - _: []ast::decl_const => "const", - _: []ast::decl_global => "let", + ast::decl_func => "fn", + []ast::decl_type => "type", + []ast::decl_const => "const", + []ast::decl_global => "let", })?; fmt::printf("<a href='#")?; unparse::ident(os::stdout, decl_ident(decl))?; @@ -184,10 +184,10 @@ fn details(ctx: *context, decl: ast::decl) (void | error) = { fmt::print("'>")?; fmt::printf("{} ", match (decl.decl) { - _: ast::decl_func => "fn", - _: []ast::decl_type => "type", - _: []ast::decl_const => "def", - _: []ast::decl_global => "let", + ast::decl_func => "fn", + []ast::decl_type => "type", + []ast::decl_const => "def", + []ast::decl_global => "let", })?; unparse::ident(os::stdout, decl_ident(decl))?; // TODO: Add source URL @@ -220,7 +220,7 @@ fn details(ctx: *context, decl: ast::decl) (void | error) = { fn htmlref(ctx: *context, ref: ast::ident) (void | io::error) = { const ik = match (resolve(ctx, ref)) { - _: void => { + void => { const ident = unparse::identstr(ref); fmt::errorfln("Warning: Unresolved reference: {}", ident)?; fmt::printf("<a href='#' " @@ -257,11 +257,11 @@ fn markup_html(ctx: *context, in: *io::stream) (void | io::error) = { let parser = parsedoc(in); for (true) { const tok = match (scandoc(&parser)) { - _: void => break, + void => break, tok: token => tok, }; match (tok) { - _: paragraph => { + paragraph => { fmt::println()?; fmt::print("<p>")?; }, @@ -559,9 +559,9 @@ fn type_html( z += fmt::fprint(out, "[")?; z += match (t.length) { expr: *ast::expr => unparse::expr(out, indent, *expr)?, - _: ast::len_slice => 0, - _: ast::len_unbounded => fmt::fprintf(out, "*")?, - _: ast::len_contextual => fmt::fprintf(out, "_")?, + ast::len_slice => 0, + ast::len_unbounded => fmt::fprintf(out, "*")?, + ast::len_contextual => fmt::fprintf(out, "_")?, }; z += fmt::fprint(out, "]")?; diff --git a/cmd/haredoc/main.ha b/cmd/haredoc/main.ha @@ -112,7 +112,7 @@ export fn main() void = { readme = readme, }; match (emit(&ctx)) { - _: void => void, + void => void, err: error => fmt::fatal("Error: {}", strerror(err)), }; }; diff --git a/cmd/haredoc/resolver.ha b/cmd/haredoc/resolver.ha @@ -23,7 +23,7 @@ fn resolve(ctx: *context, what: ast::ident) ((ast::ident, symkind) | void) = { ver: module::version => { return (what, symkind::SYMBOL); }, - _: module::error => void, + module::error => void, }; }; @@ -31,7 +31,7 @@ fn resolve(ctx: *context, what: ast::ident) ((ast::ident, symkind) | void) = { ver: module::version => { return (what, symkind::MODULE); }, - _: module::error => void, + module::error => void, }; return; diff --git a/compress/flate/inflate.ha b/compress/flate/inflate.ha @@ -104,7 +104,7 @@ fn bits(d: *decompressor, want: u32) (u32 | io::error) = { for (d.cnt < want) { let buf: [_]u8 = [0]; match (io::read(d.in, buf)?) { - _: io::EOF => return wraperror(inflate_err::EOF), + io::EOF => return wraperror(inflate_err::EOF), z: size => if (z < 1) { continue; // Short read, retry }, @@ -235,7 +235,7 @@ fn uncompressed_read(d: *decompressor) (void | io::EOF | io::error) = { d.left -= z; z; }, - _: io::EOF => return wraperror(inflate_err::EOF), + io::EOF => return wraperror(inflate_err::EOF), }; put(d, buf[..z]...); }; @@ -328,7 +328,7 @@ fn next(d: *decompressor) (void | io::EOF | io::error) = { let buf: [4]u8 = [0...]; for (let n = 0z; n < 4) { match (io::read(d.in, buf[n..])?) { - _: io::EOF => return wraperror(inflate_err::EOF), + io::EOF => return wraperror(inflate_err::EOF), z: size => n += z, }; }; @@ -358,12 +358,12 @@ fn read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = { for (n < len(buf)) { if (len(s.buf) == 0) { if (s.left == 0) match (next(s)?) { - _: void => void, - _: io::EOF => return if (n == 0) io::EOF else n, + void => void, + io::EOF => return if (n == 0) io::EOF else n, }; match (s.state(s)?) { - _: void => void, - _: io::EOF => return if (n == 0) io::EOF else n, + void => void, + io::EOF => return if (n == 0) io::EOF else n, }; }; const toread = @@ -413,7 +413,7 @@ fn close(s: *io::stream) void = { let s = inflate(ins); defer io::close(s); match (io::copy(outs, s)) { - _: size => void, + size => void, e: io::error => { fmt::errorln(io::strerror(e))!; abort(); diff --git a/compress/zlib/reader.ha b/compress/zlib/reader.ha @@ -52,7 +52,7 @@ fn verifysum(s: *reader) (io::EOF | io::error) = { for (let n = 0z; n < len(hash)) { match (io::read(s.source, hash[n..])?) { - _: io::EOF => return wraperror(decompress_err::EOF), + io::EOF => return wraperror(decompress_err::EOF), z: size => n += z, }; }; @@ -64,7 +64,7 @@ fn verifysum(s: *reader) (io::EOF | io::error) = { fn read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = { let s = s: *reader; match (io::read(s.flate, buf)?) { - _: io::EOF => return verifysum(s), + io::EOF => return verifysum(s), z: size => buf = buf[..z], }; hash::write(s.hash, buf); @@ -81,7 +81,7 @@ export fn decompress(s: *io::stream) (*io::stream | io::error) = { let buf: [2]u8 = [0...]; for (let n = 0z; n < len(buf)) { match (io::read(s, buf[n..])?) { - _: io::EOF => return wraperror(decompress_err::EOF), + io::EOF => return wraperror(decompress_err::EOF), z: size => n += z, }; }; @@ -127,7 +127,7 @@ export fn decompress(s: *io::stream) (*io::stream | io::error) = { }, }; match (io::copy(out, d)) { - _: size => void, + size => void, e: io::error => { fmt::errorfln("vector {}: {}", i, io::strerror(e))!; abort(); diff --git a/crypto/random/random.ha b/crypto/random/random.ha @@ -27,7 +27,7 @@ export let stream: *io::stream = &_stream; let buf: [4096]u8 = [0...]; let test: []u8 = []; match (io::read(stream, buf[..])) { - _: (io::error | io::EOF) => abort(), + (io::error | io::EOF) => abort(), n: size => test = buf[..n], }; diff --git a/dirs/xdg.ha b/dirs/xdg.ha @@ -19,7 +19,7 @@ fn lookup(prog: str, var: str, default: str) str = { }, }; }, - _: void => void, + void => void, }; let home = os::getenv("HOME") as str; diff --git a/encoding/hex/hex.ha b/encoding/hex/hex.ha @@ -49,7 +49,7 @@ export fn decode(s: str) ([]u8 | invalid) = { for (let i = 0z; i < len(s) / 2; i += 1) { let oct = strings::fromutf8_unsafe(s[i * 2..i * 2 + 2]); let u = match (strconv::stou8b(oct, 16)) { - _: (strconv::invalid | strconv::overflow) => return invalid, + (strconv::invalid | strconv::overflow) => return invalid, u: u8 => u, }; append(buf, u); diff --git a/encoding/utf8/decode.ha b/encoding/utf8/decode.ha @@ -93,7 +93,7 @@ export fn prev(d: *decoder) (rune | void | more | invalid) = { let decoder = decode(input); for (let i = 0z; i < len(expected); i += 1) { match (next(&decoder)) { - _: (invalid | more | void) => abort(), + (invalid | more | void) => abort(), r: rune => assert(r == expected[i]), }; }; @@ -101,7 +101,7 @@ export fn prev(d: *decoder) (rune | void | more | invalid) = { assert(decoder.offs == len(decoder.src)); for (let i = 0z; i < len(expected); i += 1) { match (prev(&decoder)) { - _: (invalid | more | void) => abort(), + (invalid | more | void) => abort(), r: rune => assert(r == expected[len(expected) - i - 1]), }; }; @@ -128,10 +128,10 @@ export fn valid(src: (str | []u8)) bool = { let decoder = decode(src); for (true) { match (next(&decoder)) { - _: void => return true, - _: invalid => return false, - _: more => return false, - _: rune => void, + void => return true, + invalid => return false, + more => return false, + rune => void, }; }; abort(); diff --git a/errors/string.ha b/errors/string.ha @@ -9,12 +9,12 @@ // strerror function which provides more context-appropriate error messages for // each of those types. export fn strerror(err: error) const str = match (err) { - _: busy => "The requested resource is not available", - _: exists => "An attempt was made to create a resource which already exists", - _: invalid => "An function was called with an invalid combination of arguments", - _: noaccess => "The user does not have permission to use this resource", - _: noentry => "An entry was requested which does not exist", - _: overflow => "The requested operation caused a numeric overflow condition", - _: unsupported => "The requested operation is not supported", + busy => "The requested resource is not available", + exists => "An attempt was made to create a resource which already exists", + invalid => "An function was called with an invalid combination of arguments", + noaccess => "The user does not have permission to use this resource", + noentry => "An entry was requested which does not exist", + overflow => "The requested operation caused a numeric overflow condition", + unsupported => "The requested operation is not supported", op: opaque => op.strerror(&op.data), }; diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -160,13 +160,13 @@ export fn fprintf( let iter = strings::iter(fmt); for (true) { let r: rune = match (strings::next(&iter)) { - _: void => break, + void => break, r: rune => r, }; if (r == '{') { r = match (strings::next(&iter)) { - _: void => abort("Invalid format string (unterminated '{')"), + void => abort("Invalid format string (unterminated '{')"), r: rune => r, }; @@ -184,7 +184,7 @@ export fn fprintf( let mod = modifiers { base = strconv::base::DEC, ... }; r = match (strings::next(&iter)) { - _: void => abort("Invalid format string (unterminated '{')"), + void => abort("Invalid format string (unterminated '{')"), r: rune => r, }; switch (r) { @@ -196,7 +196,7 @@ export fn fprintf( n += format(s, arg, &mod)?; } else if (r == '}') { match (strings::next(&iter)) { - _: void => abort("Invalid format string (hanging '}')"), + void => abort("Invalid format string (hanging '}')"), r: rune => assert(r == '}', "Invalid format string (hanging '}')"), }; @@ -269,7 +269,7 @@ fn scan_uint(iter: *strings::iterator) uint = { defer free(num); for (true) { let r = match (strings::next(iter)) { - _: void => abort("Invalid format string (unterminated '{')"), + void => abort("Invalid format string (unterminated '{')"), r: rune => r, }; @@ -278,7 +278,7 @@ fn scan_uint(iter: *strings::iterator) uint = { } else { strings::push(iter, r); match (strconv::stou(strings::fromutf8(num))) { - _: (strconv::invalid | strconv::overflow) => + (strconv::invalid | strconv::overflow) => abort("Invalid format string (invalid index)"), u: uint => return u, }; @@ -292,7 +292,7 @@ fn scan_modifier_flags(iter: *strings::iterator, mod: *modifiers) void = { for (true) { let r = match (strings::next(iter)) { - _: void => abort("Invalid format string (unterminated '{')"), + void => abort("Invalid format string (unterminated '{')"), r: rune => r, }; @@ -325,7 +325,7 @@ fn scan_modifier_flags(iter: *strings::iterator, mod: *modifiers) void = { fn scan_modifier_width(iter: *strings::iterator, mod: *modifiers) void = { let r = match (strings::next(iter)) { - _: void => abort("Invalid format string (unterminated '{')"), + void => abort("Invalid format string (unterminated '{')"), r: rune => r, }; @@ -339,7 +339,7 @@ fn scan_modifier_width(iter: *strings::iterator, mod: *modifiers) void = { fn scan_modifier_precision(iter: *strings::iterator, mod: *modifiers) void = { let r = match (strings::next(iter)) { - _: void => abort("Invalid format string (unterminated '{')"), + void => abort("Invalid format string (unterminated '{')"), r: rune => r, }; @@ -352,7 +352,7 @@ fn scan_modifier_precision(iter: *strings::iterator, mod: *modifiers) void = { fn scan_modifier_base(iter: *strings::iterator, mod: *modifiers) void = { let r = match (strings::next(iter)) { - _: void => abort("Invalid format string (unterminated '{')"), + void => abort("Invalid format string (unterminated '{')"), r: rune => r, }; @@ -373,7 +373,7 @@ fn scan_modifiers(iter: *strings::iterator, mod: *modifiers) void = { // eat '}' let terminated = match (strings::next(iter)) { - _: void => false, + void => false, r: rune => r == '}', }; assert(terminated, "Invalid format string (unterminated '{')"); diff --git a/format/html/escape.ha b/format/html/escape.ha @@ -9,7 +9,7 @@ export fn escape(out: *io::stream, in: str) (size | io::error) = { let z = 0z; let iter = strings::iter(in); for (true) match (strings::next(&iter)) { - _: void => break, + void => break, rn: rune => z += io::write(out, switch (rn) { '&' => strings::toutf8("&amp;"), '<' => strings::toutf8("&lt;"), diff --git a/format/xml/+test.ha b/format/xml/+test.ha @@ -88,8 +88,8 @@ fn xmltest(input: str, expected: []token, error: bool) void = { for (let i = 0z; i < len(expected); i += 1) { let tok = match (scan(parser)) { tok: token => tok, - _: void => abort("Expected token, got void"), - _: syntaxerr => abort("Expected token, got syntax error"), + void => abort("Expected token, got void"), + syntaxerr => abort("Expected token, got syntax error"), }; match (tok) { el: elementstart => { diff --git a/format/xml/parser.ha b/format/xml/parser.ha @@ -61,7 +61,7 @@ export fn scan(par: *parser) (token | void | error) = { * => void, }; let rn: rune = match (bufio::scanrune(par.in)?) { - _: io::EOF => if (par.state == state::ROOT) { + io::EOF => if (par.state == state::ROOT) { return syntaxerr; } else return void, rn: rune => rn, @@ -70,7 +70,7 @@ export fn scan(par: *parser) (token | void | error) = { state::ROOT, state::ELEMENT => switch (rn) { '<' => { const next = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => { bufio::unreadrune(par.in, rn); rn; @@ -132,7 +132,7 @@ fn scan_attr(par: *parser) (token | error) = { let quot = quote(par)?; strio::reset(par.textbuf); for (true) match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => { rn = switch (rn) { '<' => return syntaxerr, @@ -152,7 +152,7 @@ fn scan_attr(par: *parser) (token | error) = { fn scan_comment(par: *parser) (token | void | error) = { want(par, "<!")?; match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => switch (rn) { '-' => { // Comments want(par, '-')?; @@ -169,17 +169,17 @@ fn scan_comment(par: *parser) (token | void | error) = { }; for (true) { let rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (rn != '-') continue; let rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (rn != '-') continue; let rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (rn == '>') break; @@ -191,7 +191,7 @@ fn scan_cdata(par: *parser) (text | error) = { strio::reset(par.textbuf); for (true) { let rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (rn != ']') { @@ -199,7 +199,7 @@ fn scan_cdata(par: *parser) (text | error) = { continue; }; let rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (rn != ']') { @@ -207,7 +207,7 @@ fn scan_cdata(par: *parser) (text | error) = { continue; }; let rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (rn == '>') break; @@ -219,7 +219,7 @@ fn scan_cdata(par: *parser) (text | error) = { fn scan_content(par: *parser) (text | error) = { strio::reset(par.textbuf); for (true) match (bufio::scanrune(par.in)?) { - _: io::EOF => break, + io::EOF => break, rn: rune => { rn = switch (rn) { '<' => { @@ -241,7 +241,7 @@ fn scan_element(par: *parser) (token | error) = { want(par, '<')?; let close = false; match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => switch (rn) { '/' => close = true, * => bufio::unreadrune(par.in, rn), @@ -260,7 +260,7 @@ fn scan_element(par: *parser) (token | error) = { fn scan_entity(par: *parser) (rune | error) = { want(par, '&')?; let rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; return switch (rn) { @@ -276,7 +276,7 @@ fn scan_entity(par: *parser) (rune | error) = { fn scan_charref(par: *parser) (rune | error) = { let base = strconv::base::DEC; match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => if (rn == 'x') { base = strconv::base::HEX; } else bufio::unreadrune(par.in, rn), @@ -285,7 +285,7 @@ fn scan_charref(par: *parser) (rune | error) = { strio::reset(par.entbuf); for (true) { let rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (ascii::isdigit(rn)) { @@ -301,7 +301,7 @@ fn scan_charref(par: *parser) (rune | error) = { }; return match (strconv::stou32b(strio::string(par.entbuf), base)) { u: u32 => u: rune, - _: (strconv::invalid | strconv::overflow) => syntaxerr, + (strconv::invalid | strconv::overflow) => syntaxerr, }; }; @@ -329,7 +329,7 @@ fn scan_name(par: *parser, buf: *io::stream) (str | error) = { strio::reset(buf); const rn = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (!isnamestart(rn)) { @@ -338,7 +338,7 @@ fn scan_name(par: *parser, buf: *io::stream) (str | error) = { strio::appendrune(buf, rn)!; for (true) match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => if (isname(rn)) { strio::appendrune(buf, rn)!; } else { @@ -364,7 +364,7 @@ fn prolog(par: *parser) (void | error) = { let quot = quote(par)?; want(par, OPTWS, "1.")?; for (true) match (bufio::scanrune(par.in)?) { - _: io::EOF => break, + io::EOF => break, rn: rune => if (!ascii::isdigit(rn)) { bufio::unreadrune(par.in, rn); break; @@ -374,7 +374,7 @@ fn prolog(par: *parser) (void | error) = { let hadws = want(par, OPTWS)?; let encoding = match (bufio::scanrune(par.in)) { - _: io::EOF => false, + io::EOF => false, rn: rune => { bufio::unreadrune(par.in, rn); hadws && rn == 'e'; @@ -387,14 +387,14 @@ fn prolog(par: *parser) (void | error) = { }; // XXX: Deliberate omission: all values other than utf-8 match (ascii::strcasecmp(attr.1, "utf-8")) { - _: void => return utf8::invalid, + void => return utf8::invalid, n: int => if (n != 0) return utf8::invalid, }; }; let hadws = want(par, OPTWS)?; let standalone = match (bufio::scanrune(par.in)) { - _: io::EOF => false, + io::EOF => false, rn: rune => { bufio::unreadrune(par.in, rn); hadws && rn == 's'; @@ -407,7 +407,7 @@ fn prolog(par: *parser) (void | error) = { }; // XXX: Deliberate omission: non-standalone documents match (ascii::strcasecmp(attr.1, "yes")) { - _: void => return syntaxerr, + void => return syntaxerr, n: int => if (n != 0) return syntaxerr, }; }; @@ -437,7 +437,7 @@ fn want(par: *parser, tok: (rune | str | whitespace)...) (bool | error) = { for (let i = 0z; i < len(tok); i += 1) match (tok[i]) { x: rune => { let have = match (bufio::scanrune(par.in)?) { - _: io::EOF => return syntaxerr, + io::EOF => return syntaxerr, rn: rune => rn, }; if (have != x) { @@ -448,13 +448,13 @@ fn want(par: *parser, tok: (rune | str | whitespace)...) (bool | error) = { let iter = strings::iter(x); for (true) match (strings::next(&iter)) { rn: rune => want(par, rn)?, - _: void => break, + void => break, }; }, ws: whitespace => { let n = 0; for (true; n += 1) match (bufio::scanrune(par.in)?) { - _: io::EOF => break, + io::EOF => break, rn: rune => if (!ascii::isspace(rn)) { bufio::unreadrune(par.in, rn); break; diff --git a/format/xml/types.ha b/format/xml/types.ha @@ -45,8 +45,8 @@ export type error = (syntaxerr | utf8::invalid | io::error)!; // Converts an [[error]] to a user-friendly string representation. export fn strerror(err: error) const str = { return match (err) { - _: syntaxerr => "Syntax error", - _: utf8::invalid => "Document is not valid UTF-8", + syntaxerr => "Syntax error", + utf8::invalid => "Document is not valid UTF-8", err: io::error => io::strerror(err), }; }; diff --git a/fs/fs.ha b/fs/fs.ha @@ -87,15 +87,15 @@ export fn mkdirs(fs: *fs, path: str) (void | error) = { let parent = path::dirname(path); if (path != parent) { match (mkdirs(fs, parent)) { - _: errors::exists => void, + errors::exists => void, err: error => return err, - _: void => void, + void => void, }; }; return match (mkdir(fs, path)) { - _: errors::exists => void, + errors::exists => void, err: error => err, - _: void => void, + void => void, }; }; @@ -126,7 +126,7 @@ export fn rmdirall(fs: *fs, path: str) (void | error) = { * => remove(fs, p)?, }; }, - _: void => break, + void => break, }; if (path != "") { return rmdir(fs, path); diff --git a/fs/mem/+test.ha b/fs/mem/+test.ha @@ -56,7 +56,7 @@ use strconv; defer free(it); let count = 0z; for (true) match (it.next(it)) { - _: void => break, + void => break, d: fs::dirent => count += 1, }; assert(count == 6); @@ -132,7 +132,7 @@ use strconv; defer free(it); let count = 0z; for (true) match (it.next(it)) { - _: void => break, + void => break, d: fs::dirent => count += 1, }; assert(count == limit); diff --git a/fs/mem/mem.ha b/fs/mem/mem.ha @@ -96,7 +96,7 @@ fn create( let parent = fs: *inode; match (inode_find(parent, path)) { - _: errors::noentry => void, + errors::noentry => void, * => return errors::exists, }; if (path::dirname(path) != path) { @@ -130,7 +130,7 @@ fn open( fn stat(fs: *fs::fs, path: str) (fs::filestat | fs::error) = { return match(inode_find(fs: *inode, path)?.data) { - _: directory => fs::filestat { mode = fs::mode::DIR | 0o777, ... }, + directory => fs::filestat { mode = fs::mode::DIR | 0o777, ... }, f: file => fs::filestat { mode = fs::mode::REG | 0o777, mask = fs::stat_mask::SIZE, @@ -148,7 +148,7 @@ fn mkdir(fs: *fs::fs, path: str) (void | fs::error) = { fn mksubdir(fs: *fs::fs, path: str) (*fs::fs | fs::error) = { let parent = fs: *inode; match (inode_find(parent, path)) { - _: errors::noentry => void, + errors::noentry => void, * => return errors::exists, }; if (path::dirname(path) != path) { @@ -195,8 +195,8 @@ fn next(iter: *fs::iterator) (fs::dirent | void) = match (_next(iter)) { ino: *inode => fs::dirent { name = ino.name, ftype = match (ino.data) { - _: directory => fs::mode::DIR, - _: file => fs::mode::REG, + directory => fs::mode::DIR, + file => fs::mode::REG, }, }, }; @@ -264,8 +264,8 @@ fn close_rec(ino: *inode) void = { ino: *inode => { ino.parent = null; match (ino.data) { - _: file => inode_free(ino), - _: directory => close_rec(ino), + file => inode_free(ino), + directory => close_rec(ino), * => abort("unreachable"), }; }, diff --git a/fs/mem/util.ha b/fs/mem/util.ha @@ -102,7 +102,7 @@ fn find_rec(dir: *inode, name: str, it: *path::iterator) (*inode | fs::error) = ino: *inode => { if (name == ino.name) { return match (path::next(it)) { - _: void => ino, + void => ino, name: str => find_rec(ino, name, it), }; }; diff --git a/fs/util.ha b/fs/util.ha @@ -5,10 +5,10 @@ use strings; // Returns a human-friendly representation of an error. export fn strerror(err: error) const str = match (err) { - _: errors::noentry => "File or directory not found", - _: errors::noaccess => "Permission denied", - _: errors::exists => "File or directory exists", - _: errors::invalid => "Invalid argument", + errors::noentry => "File or directory not found", + errors::noaccess => "Permission denied", + errors::exists => "File or directory exists", + errors::invalid => "Invalid argument", err: io::error => io::strerror(err), }; @@ -87,7 +87,7 @@ export fn readdir(fs: *fs, path: str) ([]dirent | error) = { for (true) { match (next(i)) { d: dirent => append(ents, dirent_dup(&d)), - _: void => break, + void => break, }; }; return ents; diff --git a/getopt/getopts.ha b/getopt/getopts.ha @@ -126,7 +126,7 @@ export fn parse(args: []str, help: help...) command = { const r = next as rune; :help for (let j = 0z; j < len(help); j += 1) { let p: parameter_help = match (help[j]) { - _: cmd_help => continue :help, + cmd_help => continue :help, f: flag_help => if (r == f.0) { append(opts, (r, "")); continue :flag; @@ -156,9 +156,9 @@ export fn parse(args: []str, help: help...) command = { os::exit(1); }; match (next) { - _: rune => abort(), // Unreachable - _: void => void, - _: (utf8::more | utf8::invalid) => { + rune => abort(), // Unreachable + void => void, + (utf8::more | utf8::invalid) => { errmsg(args[9], "invalid UTF-8 in arguments", void, help); os::exit(1); @@ -225,8 +225,8 @@ export fn printhelp(s: *io::stream, name: str, help: []help) void = { printusage(s, name, help); for (let i = 0z; i < len(help); i += 1) match (help[i]) { - _: cmd_help => void, - _: (flag_help | parameter_help) => { + cmd_help => void, + (flag_help | parameter_help) => { // Only print this if there are flags to show fmt::fprint(s, "\n")!; break; @@ -234,7 +234,7 @@ export fn printhelp(s: *io::stream, name: str, help: []help) void = { }; for (let i = 0z; i < len(help); i += 1) match (help[i]) { - _: cmd_help => void, + cmd_help => void, f: flag_help => { fmt::fprintfln(s, "-{}: {}", f.0: rune, f.1)!; }, @@ -247,7 +247,7 @@ export fn printhelp(s: *io::stream, name: str, help: []help) void = { fn errmsg(name: str, err: str, opt: (rune | void), help: []help) void = { fmt::errorfln("{}: {}{}", name, err, match (opt) { r: rune => r, - _: void => "", + void => "", })!; printusage(os::stderr, name, help); }; diff --git a/hare/ast/expr.ha b/hare/ast/expr.ha @@ -418,7 +418,7 @@ export fn expr_free(e: (expr | nullable *expr)) void = match (e) { expr_free(c._type); }, c: constant_expr => match(c) { - _: (void | lex::value) => void, + (void | lex::value) => void, a: array_constant => { for (let i = 0z; i < len(a.values); i += 1) { expr_free(a.values[i]); diff --git a/hare/ast/type.ha b/hare/ast/type.ha @@ -157,7 +157,7 @@ export fn type_free(t: (_type | nullable *_type)) void = match (t) { }, t: _type => match (t._type) { a: alias_type => ident_free(a.ident), - _: builtin_type => void, + builtin_type => void, e: enum_type => { for (let i = 0z; i < len(e.values); i += 1) { free(e.values[i].name); diff --git a/hare/lex/+test.ha b/hare/lex/+test.ha @@ -38,7 +38,7 @@ fn vassert(expected: value, actual: value) void = match (expected) { expected: i64 => assert(actual as i64 == expected), expected: u64 => assert(actual as u64 == expected), expected: f64 => assert(actual as f64 == expected), - _: void => assert(actual is void), + void => assert(actual is void), }; fn lextest(in: str, expected: []token) void = { diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -69,12 +69,12 @@ export fn lex(lex: *lexer) (token | error) = { lex.un = void; return tok; }, - _: void => void, + void => void, }; let loc = location { ... }; let r: rune = match (nextw(lex)?) { - _: io::EOF => return (ltok::EOF, void, mkloc(lex)), + io::EOF => return (ltok::EOF, void, mkloc(lex)), r: (rune, location) => { loc = r.1; r.0; @@ -120,7 +120,7 @@ fn is_name(r: rune, num: bool) bool = fn ncmp(a: const *void, b: const *void) int = { let a = a: const *str, b = b: const *str; return match (ascii::strcmp(*a, *b)) { - _: void => abort("non-ascii name"), // TODO: Bubble me up + void => abort("non-ascii name"), // TODO: Bubble me up i: int => i, }; }; @@ -130,7 +130,7 @@ fn lex_unicode(lex: *lexer, loc: location, n: size) (rune | error) = { let buf: [9]u8 = [0...]; for (let i = 0z; i < n; i += 1z) { let r = match (next(lex)?) { - _: io::EOF => return syntaxerr(loc, + io::EOF => return syntaxerr(loc, "unexpected EOF scanning for escape"), r: rune => r, }; @@ -146,7 +146,7 @@ fn lex_unicode(lex: *lexer, loc: location, n: size) (rune | error) = { fn lex_rune(lex: *lexer, loc: location) (rune | error) = { let r = match (next(lex)?) { - _: io::EOF => return syntaxerr(loc, + io::EOF => return syntaxerr(loc, "unexpected EOF scanning for rune"), r: rune => r, }; @@ -154,7 +154,7 @@ fn lex_rune(lex: *lexer, loc: location) (rune | error) = { return r; }; r = match (next(lex)?) { - _: io::EOF => return syntaxerr(loc, + io::EOF => return syntaxerr(loc, "unexpected EOF scanning for escape"), r: rune => r, }; @@ -179,7 +179,7 @@ fn lex_rune(lex: *lexer, loc: location) (rune | error) = { fn lex_string(lex: *lexer, loc: location) (token | error) = { let buf = strio::dynamic(); for (true) match (next(lex)?) { - _: io::EOF => return syntaxerr(loc, "unexpected EOF scanning string literal"), + io::EOF => return syntaxerr(loc, "unexpected EOF scanning string literal"), r: rune => if (r == '"') break else { @@ -189,7 +189,7 @@ fn lex_string(lex: *lexer, loc: location) (token | error) = { }, }; match (nextw(lex)?) { - _: io::EOF => void, + io::EOF => void, r: (rune, location) => { const r = r.0; if (r == '"') { @@ -208,7 +208,7 @@ fn lex_string(lex: *lexer, loc: location) (token | error) = { fn lex_rn_str(lex: *lexer, loc: location) (token | error) = { let r = match (next(lex)) { r: rune => r, - _: (io::EOF | io::error) => abort(), + (io::EOF | io::error) => abort(), }; switch (r) { '\"' => return lex_string(lex, loc), @@ -219,7 +219,7 @@ fn lex_rn_str(lex: *lexer, loc: location) (token | error) = { // Rune literal let ret: token = (ltok::LIT_RUNE, lex_rune(lex, loc)?, loc); match (next(lex)?) { - _: io::EOF => + io::EOF => return syntaxerr(loc, "unexpected EOF"), n: rune => if (n != '\'') return syntaxerr(loc, "expected \"\'\""), @@ -234,11 +234,11 @@ fn lex_name(lex: *lexer, loc: location, keyword: bool) (token | error) = { assert(is_name(r, false)); strio::appendrune(buf, r)!; }, - _: (io::EOF | io::error) => abort(), + (io::EOF | io::error) => abort(), }; for (true) match (next(lex)?) { - _: io::EOF => break, + io::EOF => break, r: rune => { if (!is_name(r, true)) { unget(lex, r); @@ -268,7 +268,7 @@ fn lex_name(lex: *lexer, loc: location, keyword: bool) (token | error) = { fn lex_comment(lexr: *lexer, loc: location) (token | error) = { if (lexr.flags & flags::COMMENTS != flags::COMMENTS) { for (true) match (next(lexr)?) { - _: io::EOF => break, + io::EOF => break, r: rune => if (r == '\n') break, }; return lex(lexr); @@ -277,7 +277,7 @@ fn lex_comment(lexr: *lexer, loc: location) (token | error) = { let buf = strio::dynamic(); defer io::close(buf); for (true) match (next(lexr)?) { - _: io::EOF => break, + io::EOF => break, r: rune => { strio::appendrune(buf, r)!; if (r == '\n') break; @@ -292,13 +292,13 @@ fn lex_comment(lexr: *lexer, loc: location) (token | error) = { fn lex_literal(lex: *lexer, loc: location) (token | error) = { let chars: []u8 = []; let r = match (next(lex)?) { - _: io::EOF => return (ltok::EOF, void, loc), + io::EOF => return (ltok::EOF, void, loc), r: rune => r, }; if (r == '-') { append(chars, utf8::encoderune(r)...); r = match (next(lex)?) { - _: io::EOF => return (ltok::EOF, void, loc), + io::EOF => return (ltok::EOF, void, loc), r: rune => r, }; }; @@ -307,7 +307,7 @@ fn lex_literal(lex: *lexer, loc: location) (token | error) = { if (r == '0') { append(chars, utf8::encoderune(r)...); r = match (next(lex)?) { - _: io::EOF => return (ltok::LIT_ICONST, 0i64, loc), + io::EOF => return (ltok::LIT_ICONST, 0i64, loc), r: rune => r, }; switch (r) { @@ -330,7 +330,7 @@ fn lex_literal(lex: *lexer, loc: location) (token | error) = { let float = false; for (true) { r = match (next(lex)?) { - _: io::EOF => break, + io::EOF => break, r: rune => r, }; if (!strings::contains(basechrs, r)) switch (r) { @@ -340,7 +340,7 @@ fn lex_literal(lex: *lexer, loc: location) (token | error) = { break; } else { r = match (next(lex)?) { - _: io::EOF => break, + io::EOF => break, r: rune => r, }; if (!strings::contains(basechrs, r)) { @@ -378,10 +378,10 @@ fn lex_literal(lex: *lexer, loc: location) (token | error) = { if (end == 0) end = len(chars); let exp = match (exp) { - _: void => "0", + void => "0", exp: size => { let end = match (suff) { - _: void => len(chars), + void => len(chars), suff: size => suff, }; strings::fromutf8(chars[exp..end]); @@ -389,14 +389,14 @@ fn lex_literal(lex: *lexer, loc: location) (token | error) = { }; let exp = match (strconv::stoz(exp)) { exp: size => exp, - _: strconv::invalid => abort(), // Shouldn't be lexed in - _: strconv::overflow => + strconv::invalid => abort(), // Shouldn't be lexed in + strconv::overflow => return syntaxerr(loc, "overflow in exponent"), }; let suff = match (suff) { suff: size => strings::fromutf8(chars[suff..]), - _: void => "", + void => "", }; let suff = if (suff == "u8") ltok::LIT_U8 else if (suff == "u16") ltok::LIT_U16 @@ -421,8 +421,8 @@ fn lex_literal(lex: *lexer, loc: location) (token | error) = { ltok::LIT_UINT, ltok::LIT_SIZE => strconv::stou64b(val, base), ltok::LIT_ICONST => match (strconv::stoi64b(val, base)) { i: i64 => i, - _: strconv::invalid => abort(), - _: strconv::overflow => if (chars[0] != '-': u32: u8) { + strconv::invalid => abort(), + strconv::overflow => if (chars[0] != '-': u32: u8) { suff = ltok::LIT_U64; strconv::stou64b(val, base); } else strconv::overflow, @@ -444,8 +444,8 @@ fn lex_literal(lex: *lexer, loc: location) (token | error) = { }; val; }, - _: strconv::invalid => abort(), // Shouldn't be lexed in - _: strconv::overflow => + strconv::invalid => abort(), // Shouldn't be lexed in + strconv::overflow => return syntaxerr(loc, "overflow in exponent"), }; @@ -461,14 +461,14 @@ fn lex2(lexr: *lexer, loc: location, r: rune) (token | error) = { '=' => return (ltok::BXOREQ, void, loc), * => ltok::BXOR, }, - _: io::EOF => ltok::BXOR, + io::EOF => ltok::BXOR, }, '*' => match (n) { r: rune => switch (r) { '=' => return (ltok::TIMESEQ, void, loc), * => ltok::TIMES, }, - _: io::EOF => ltok::TIMES, + io::EOF => ltok::TIMES, }, '/' => match (n) { r: rune => switch (r) { @@ -476,21 +476,21 @@ fn lex2(lexr: *lexer, loc: location, r: rune) (token | error) = { '/' => return lex_comment(lexr, loc), * => ltok::DIV, }, - _: io::EOF => ltok::DIV, + io::EOF => ltok::DIV, }, '%' => match (n) { r: rune => switch (r) { '=' => return (ltok::MODEQ, void, loc), * => ltok::MODULO, }, - _: io::EOF => ltok::MODULO, + io::EOF => ltok::MODULO, }, '+' => match (n) { r: rune => switch (r) { '=' => return (ltok::PLUSEQ, void, loc), * => ltok::PLUS, }, - _: io::EOF => ltok::PLUS, + io::EOF => ltok::PLUS, }, '-' => match (n) { r: rune => switch (r) { @@ -503,7 +503,7 @@ fn lex2(lexr: *lexer, loc: location, r: rune) (token | error) = { ltok::MINUS; }, }, - _: io::EOF => ltok::MINUS, + io::EOF => ltok::MINUS, }, ':' => match (n) { r: rune => switch (r) { @@ -515,14 +515,14 @@ fn lex2(lexr: *lexer, loc: location, r: rune) (token | error) = { return tok; } else ltok::COLON, }, - _: io::EOF => ltok::COLON, + io::EOF => ltok::COLON, }, '!' => match (n) { r: rune => switch (r) { '=' => return (ltok::NEQUAL, void, loc), * => ltok::LNOT, }, - _: io::EOF => ltok::LNOT, + io::EOF => ltok::LNOT, }, '&' => match (n) { r: rune => switch (r) { @@ -530,7 +530,7 @@ fn lex2(lexr: *lexer, loc: location, r: rune) (token | error) = { '=' => return (ltok::ANDEQ, void, loc), * => ltok::BAND, }, - _: io::EOF => ltok::BAND, + io::EOF => ltok::BAND, }, '|' => match (n) { r: rune => switch (r) { @@ -538,7 +538,7 @@ fn lex2(lexr: *lexer, loc: location, r: rune) (token | error) = { '=' => return (ltok::OREQ, void, loc), * => ltok::BOR, }, - _: io::EOF => ltok::BOR, + io::EOF => ltok::BOR, }, '=' => match (n) { r: rune => switch (r) { @@ -546,7 +546,7 @@ fn lex2(lexr: *lexer, loc: location, r: rune) (token | error) = { '>' => return (ltok::CASE, void, loc), * => ltok::EQUAL, }, - _: io::EOF => ltok::EQUAL, + io::EOF => ltok::EQUAL, }, * => return syntaxerr(loc, "unknown token sequence"), }; @@ -556,7 +556,7 @@ fn lex2(lexr: *lexer, loc: location, r: rune) (token | error) = { fn lex3(lex: *lexer, loc: location, r: rune) (token | error) = { let n = match (next(lex)?) { - _: io::EOF => return switch (r) { + io::EOF => return switch (r) { '.' => (ltok::DOT, void, loc), '<' => (ltok::LESS, void, loc), '>' => (ltok::GREATER, void, loc), @@ -576,7 +576,7 @@ fn lex3dot(lex: *lexer, loc: location, n: rune) (token | error) = { let tok: ltok = switch (n) { '.' => { let q = match (next(lex)?) { - _: io::EOF => io::EOF, + io::EOF => io::EOF, r: rune => r, }; let t = match (q) { @@ -584,7 +584,7 @@ fn lex3dot(lex: *lexer, loc: location, n: rune) (token | error) = { '.' => return (ltok::ELLIPSIS, void, loc), * => ltok::SLICE, }, - _: io::EOF => ltok::SLICE, + io::EOF => ltok::SLICE, }; unget(lex, q); t; @@ -601,7 +601,7 @@ fn lex3lt(lex: *lexer, loc: location, n: rune) (token | error) = { let tok: ltok = switch (n) { '<' => { let q = match (next(lex)?) { - _: io::EOF => io::EOF, + io::EOF => io::EOF, r: rune => r, }; let t = match (q) { @@ -609,7 +609,7 @@ fn lex3lt(lex: *lexer, loc: location, n: rune) (token | error) = { '=' => return (ltok::LSHIFTEQ, void, loc), * => ltok::LSHIFT, }, - _: io::EOF => ltok::LSHIFT, + io::EOF => ltok::LSHIFT, }; unget(lex, q); t; @@ -627,7 +627,7 @@ fn lex3gt(lex: *lexer, loc: location, n: rune) (token | error) = { let tok: ltok = switch (n) { '>' => { let q = match (next(lex)?) { - _: io::EOF => io::EOF, + io::EOF => io::EOF, r: rune => r, }; let t = match (q) { @@ -635,7 +635,7 @@ fn lex3gt(lex: *lexer, loc: location, n: rune) (token | error) = { '=' => return (ltok::RSHIFTEQ, void, loc), * => ltok::RSHIFT, }, - _: io::EOF => ltok::RSHIFT, + io::EOF => ltok::RSHIFT, }; unget(lex, q); t; @@ -659,7 +659,7 @@ export fn unlex(lex: *lexer, tok: token) void = { fn next(lex: *lexer) (rune | io::EOF | io::error) = { match (lex.rb[0]) { - _: void => void, + void => void, r: (rune | io::EOF) => { lex.rb[0] = lex.rb[1]; lex.rb[1] = void; diff --git a/hare/module/context.ha b/hare/module/context.ha @@ -32,7 +32,7 @@ export fn context_init(tags: []tag, defs: []str, harepath: str) context = { tags = tags, defines = defs, paths: []str = match (os::getenv("HAREPATH")) { - _: void => { + void => { let path: []str = alloc([ strings::dup(harepath), dirs::data("hare"), @@ -51,7 +51,7 @@ export fn context_init(tags: []tag, defs: []str, harepath: str) context = { }, }, cache: str = match (os::getenv("HARECACHE")) { - _: void => dirs::cache("hare"), + void => dirs::cache("hare"), s: str => strings::dup(s), }, ... diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha @@ -57,7 +57,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { defer unlock(ctx.fs, cachedir, l); let file = match (fs::open(ctx.fs, mpath, fs::flags::RDONLY)) { - _: errors::noentry => return manifest, + errors::noentry => return manifest, err: fs::error => return err, file: *io::stream => file, }; @@ -69,10 +69,10 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { let file = bufio::buffered(file, buf, []); for (true) { let line = match (bufio::scanline(file)?) { - _: io::EOF => break, + io::EOF => break, line: []u8 => match (strings::try_fromutf8(line)) { // Treat an invalid manifest as empty - _: utf8::invalid => return manifest, + utf8::invalid => return manifest, s: str => s, }, }; @@ -84,13 +84,13 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { let tok = strings::tokenize(line, " "); let kind = match (strings::next_token(&tok)) { - _: void => continue, + void => continue, s: str => s, }; if (kind == "version") { let ver = match (strings::next_token(&tok)) { - _: void => return manifest, + void => return manifest, s: str => s, }; match (strconv::stoi(ver)) { @@ -101,13 +101,13 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { }; } else if (kind == "input") { let hash = match (strings::next_token(&tok)) { - _: void => return manifest, s: str => s, + void => return manifest, s: str => s, }, path = match (strings::next_token(&tok)) { - _: void => return manifest, s: str => s, + void => return manifest, s: str => s, }, inode = match (strings::next_token(&tok)) { - _: void => return manifest, s: str => s, + void => return manifest, s: str => s, }, mtime = match (strings::next_token(&tok)) { - _: void => return manifest, s: str => s, + void => return manifest, s: str => s, }; let hash = match (hex::decode(hash)) { @@ -125,7 +125,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { let parsed = parse_name(path); let ftype = match (type_for_ext(path)) { - _: void => return manifest, + void => return manifest, ft: filetype => ft, }; @@ -143,7 +143,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { }); } else if (kind == "module") { let modhash = match (strings::next_token(&tok)) { - _: void => return manifest, s: str => s, + void => return manifest, s: str => s, }; let modhash = match (hex::decode(modhash)) { * => return manifest, @@ -153,7 +153,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { let minputs: []input = []; for (true) { let hash = match (strings::next_token(&tok)) { - _: void => break, + void => break, s: str => s, }; let hash = match (hex::decode(hash)) { @@ -179,7 +179,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = { // Check for extra tokens match (strings::next_token(&tok)) { - _: void => void, + void => void, s: str => return manifest, }; }; @@ -281,8 +281,8 @@ fn lock(fs: *fs::fs, cachedir: str) (*io::stream | error) = { // XXX: I wonder if this should be some generic function in fs or // something match (os::mkdirs(cachedir)) { - _: errors::exists => void, - _: void => void, + errors::exists => void, + void => void, e: fs::error => return e, }; let lockpath = path::join(cachedir, "manifest.lock"); @@ -292,7 +292,7 @@ fn lock(fs: *fs::fs, cachedir: str) (*io::stream | error) = { for (true) { match (fs::create(fs, lockpath, 0o644, fs::flags::EXCL)) { fd: *io::stream => return fd, - _: (errors::busy | errors::exists) => void, + (errors::busy | errors::exists) => void, err: fs::error => return err, }; if (!logged) { @@ -309,7 +309,7 @@ fn unlock(fs: *fs::fs, cachedir: str, s: *io::stream) void = { let lockpath = path::join(cachedir, "manifest.lock"); defer free(lockpath); match (fs::remove(fs, lockpath)) { - _: void => void, + void => void, err: fs::error => abort("Error removing module lock"), }; }; diff --git a/hare/module/scan.ha b/hare/module/scan.ha @@ -22,12 +22,12 @@ export fn scan(ctx: *context, path: str) (version | error) = { let sha = sha256::sha256(); //defer! hash::close(sha); let iter = match (fs::iter(ctx.fs, path)) { - _: fs::wrongtype => { + fs::wrongtype => { // Single file case let inputs: []input = []; let deps: []ast::ident = []; let ft = match (type_for_ext(path)) { - _: void => return module_not_found, + void => return module_not_found, ft: filetype => ft, }; let st = fs::stat(ctx.fs, path)?; @@ -86,7 +86,7 @@ fn parse_name(name: str) (str, str, []tag) = { else p: size; let tags = strings::sub(base, i, strings::end); let tags = match (parsetags(tags)) { - _: void => return (base, ext, []), + void => return (base, ext, []), t: []tag => t, }; let base = strings::sub(base, 0, i); @@ -121,7 +121,7 @@ fn scan_directory( for (true) { let ent = match (fs::next(iter)) { - _: void => break, + void => break, ent: fs::dirent => ent, }; @@ -355,7 +355,7 @@ export fn parsetags(in: str) ([]tag | void) = { for (true) { let t = tag { ... }; let m = match (strings::next(&iter)) { - _: void => break, + void => break, r: rune => r, }; t.mode = switch (m) { @@ -365,7 +365,7 @@ export fn parsetags(in: str) ([]tag | void) = { }; let buf = strio::dynamic(); for (true) match (strings::next(&iter)) { - _: void => break, + void => break, r: rune => { if (ascii::isalnum(r) || r == '_') { strio::appendrune(buf, r)!; diff --git a/hare/module/types.ha b/hare/module/types.ha @@ -72,7 +72,7 @@ export fn strerror(err: error) const str = { err: fs::error => fs::strerror(err), err: io::error => io::strerror(err), err: parse::error => parse::strerror(err), - _: module_not_found => "Module not found", + module_not_found => "Module not found", amb: ambiguous => fmt::bsprintf(buf, "Cannot choose between {} and {}", amb.0, amb.1), }; diff --git a/hare/parse/decl.ha b/hare/parse/decl.ha @@ -11,13 +11,13 @@ fn attr_symbol(lexer: *lex::lexer) (str | error) = { let s = t.1 as str; let d = strings::iter(s); match (strings::next(&d)) { - _: void => void, + void => void, r: rune => synassert(t.2, ascii::isalpha(r) || r == '.' || r == '_', "Invalid symbol")?, }; for (true) match (strings::next(&d)) { - _: void => break, + void => break, r: rune => synassert(t.2, ascii::isalnum(r) || r == '$' || r == '.' || r == '_', "Invalid symbol")?, @@ -58,16 +58,16 @@ fn decl_global( let decl: []ast::decl_global = []; for (true) { const symbol = match (try(lexer, ltok::ATTR_SYMBOL)?) { - _: void => "", - _: lex::token => attr_symbol(lexer)?, + void => "", + lex::token => attr_symbol(lexer)?, }; const ident = ident(lexer)?; want(lexer, ltok::COLON)?; const _type = _type(lexer)?; const init: nullable *ast::expr = match (try(lexer, ltok::EQUAL)?) { - _: lex::token => alloc(expression(lexer)?), - _: void => null, + lex::token => alloc(expression(lexer)?), + void => null, }; const btok = try(lexer, ltok::COMMA)?; append(decl, ast::decl_global { @@ -78,7 +78,7 @@ fn decl_global( init = init, }); match (btok) { - _: void => break, + void => break, * => void, }; }; @@ -97,7 +97,7 @@ fn decl_type(lexer: *lex::lexer) ([]ast::decl_type | error) = { _type = _type, }); match (btok) { - _: void => break, + void => break, * => void, }; }; @@ -111,7 +111,7 @@ fn decl_func(lexer: *lex::lexer) (ast::decl_func | error) = { ltok::ATTR_NORETURN, ltok::ATTR_SYMBOL ]; for (true) match (try(lexer, attrs...)?) { - _: void => break, + void => break, t: lex::token => switch (t.0) { ltok::ATTR_FINI => attr = ast::fndecl_attrs::FINI, ltok::ATTR_INIT => attr = ast::fndecl_attrs::INIT, @@ -167,8 +167,8 @@ export fn decls(lexer: *lex::lexer) ([]ast::decl | error) = { if (peek(lexer, ltok::EOF)? is lex::token) break; let comment = ""; let exported = match (try(lexer, ltok::EXPORT)?) { - _: void => false, - _: lex::token => { + void => false, + lex::token => { comment = strings::dup(lex::comment(lexer)); true; }, @@ -179,7 +179,7 @@ export fn decls(lexer: *lex::lexer) ([]ast::decl | error) = { comment = strings::dup(lex::comment(lexer)); }; let decl = match (next) { - _: void => decl_func(lexer)?, + void => decl_func(lexer)?, t: lex::token => switch (t.0) { ltok::TYPE => decl_type(lexer)?, ltok::LET, ltok::CONST => diff --git a/hare/parse/expr.ha b/hare/parse/expr.ha @@ -6,8 +6,8 @@ use strings; // Parses an expression. export fn expression(lexer: *lex::lexer) (ast::expr | error) = { const indirect = match (try(lexer, ltok::TIMES)?) { - _: void => false, - _: lex::token => true, + void => false, + lex::token => true, }; // All assignment-op tokens @@ -33,7 +33,7 @@ export fn expression(lexer: *lex::lexer) (ast::expr | error) = { ltok::SWITCH, ltok::IF, ltok::LABEL, ltok::FOR, ltok::BREAK, ltok::CONTINUE, ltok::RETURN, ltok::LET, ltok::CONST)?) { - _: void => binarithm(lexer, void, 0)?, + void => binarithm(lexer, void, 0)?, tok: lex::token => switch (tok.0) { ltok::LBRACE => expression_list(lexer)?, ltok::MATCH => match_expr(lexer)?, @@ -204,7 +204,7 @@ fn binarithm( // Precedence climbing parser // https://en.wikipedia.org/wiki/Operator-precedence_parser let lvalue = match (lvalue) { - _: void => cast(lexer, void)?, + void => cast(lexer, void)?, expr: ast::expr => expr, }; @@ -254,8 +254,8 @@ fn binding(lexer: *lex::lexer, is_static: bool) (ast::expr | error) = { init = init, }); match (try(lexer, ltok::COMMA)?) { - _: void => break, - _: lex::token => void, + void => break, + lex::token => void, }; }; @@ -271,7 +271,7 @@ fn builtin(lexer: *lex::lexer) (ast::expr | error) = { ltok::DELETE, ltok::ABORT, ltok::ASSERT, ltok::STATIC, ltok::SIZE, ltok::LEN, ltok::OFFSET, ltok::DEFER)?) { tok: lex::token => tok, - _: void => return postfix(lexer, void), + void => return postfix(lexer, void), }; return switch (tok.0) { ltok::ALLOC => alloc_expr(lexer), @@ -285,7 +285,7 @@ fn builtin(lexer: *lex::lexer) (ast::expr | error) = { ltok::ABORT, ltok::ASSERT)?) { tok: lex::token => tok, // TODO: The following is lame - _: void => return syntaxerr(tok.2, + void => return syntaxerr(tok.2, "Expected let, const, or assert"), }; switch (tok.0) { @@ -310,20 +310,20 @@ fn call(lexer: *lex::lexer, lvalue: ast::expr) (ast::expr | error) = { for (true) { match (try(lexer, ltok::RPAREN)?) { - _: lex::token => break, - _: void => void, + lex::token => break, + void => void, }; append(args, alloc(expression(lexer)?)); match (try(lexer, ltok::ELLIPSIS)?) { - _: lex::token => { + lex::token => { variadic = true; try(lexer, ltok::COMMA)?; want(lexer, ltok::RPAREN)?; break; }, - _: void => void, + void => void, }; switch (want(lexer, ltok::COMMA, ltok::RPAREN)?.0) { @@ -341,12 +341,12 @@ fn call(lexer: *lex::lexer, lvalue: ast::expr) (ast::expr | error) = { fn cast(lexer: *lex::lexer, lvalue: (ast::expr | void)) (ast::expr | error) = { const lvalue = match (lvalue) { - _: void => unarithm(lexer)?, + void => unarithm(lexer)?, e: ast::expr => e, }; const tok = match (try(lexer, ltok::COLON, ltok::AS, ltok::IS)?) { - _: void => return lvalue, + void => return lvalue, tok: lex::token => tok.0, }; const kind = switch (tok) { @@ -383,15 +383,15 @@ fn control(lexer: *lex::lexer) (ast::expr | error) = { let label = if (tok.0 == ltok::BREAK || tok.0 == ltok::CONTINUE) { match (try(lexer, ltok::LABEL)?) { tok: lex::token => tok.1 as str, - _: void => "", + void => "", }; } else ""; return switch (tok.0) { ltok::BREAK => label: ast::break_expr, ltok::CONTINUE => label: ast::continue_expr, ltok::RETURN => match (peek(lexer, ltok::COMMA, ltok::SEMICOLON)?) { - _: void => alloc(expression(lexer)?): ast::return_expr, - _: lex::token => null: ast::return_expr, + void => alloc(expression(lexer)?): ast::return_expr, + lex::token => null: ast::return_expr, }, }; }; @@ -411,8 +411,8 @@ fn expression_list(lexer: *lex::lexer) (ast::expr | error) = { want(lexer, ltok::LBRACE)?; for (let more = true; more) { const item = match (peek(lexer, ltok::RBRACE)?) { - _: lex::token => break, - _: void => expression(lexer)?, + lex::token => break, + void => expression(lexer)?, }; append(items, alloc(item)); want(lexer, ltok::SEMICOLON)?; @@ -436,8 +436,8 @@ fn for_expr(lexer: *lex::lexer) (ast::expr | error) = { const bindings: nullable *ast::expr = match (peek( lexer, ltok::LET, ltok::CONST)?) { - _: void => null, - _: lex::token => { + void => null, + lex::token => { const bindings = alloc(binding(lexer, false)?); want(lexer, ltok::SEMICOLON)?; bindings; @@ -448,8 +448,8 @@ fn for_expr(lexer: *lex::lexer) (ast::expr | error) = { const afterthought: nullable *ast::expr = match (peek( lexer, ltok::SEMICOLON)) { - _: void => null, - _: lex::token => { + void => null, + lex::token => { want(lexer, ltok::SEMICOLON)?; alloc(expression(lexer)?); }, @@ -481,8 +481,8 @@ fn if_expr(lexer: *lex::lexer) (ast::expr | error) = { want(lexer, ltok::RPAREN)?; const tbranch = alloc(expression(lexer)?); const fbranch: nullable *ast::expr = match (try(lexer, ltok::ELSE)?) { - _: void => null, - _: lex::token => alloc(expression(lexer)?), + void => null, + lex::token => alloc(expression(lexer)?), }; return ast::if_expr { cond = cond, @@ -496,16 +496,16 @@ fn indexing(lexer: *lex::lexer, lvalue: ast::expr) (ast::expr | error) = { let start: nullable *ast::expr = null, end: nullable *ast::expr = null; match (try(lexer, ltok::SLICE)?) { - _: void => start = alloc(expression(lexer)?), - _: lex::token => is_slice = true, + void => start = alloc(expression(lexer)?), + lex::token => is_slice = true, }; if (!is_slice) match (try(lexer, ltok::SLICE)?) { - _: void => void, - _: lex::token => is_slice = true, + void => void, + lex::token => is_slice = true, }; if (is_slice) match (peek(lexer, ltok::RBRACKET)?) { - _: lex::token => void, - _: void => end = alloc(expression(lexer)?), + lex::token => void, + void => end = alloc(expression(lexer)?), }; want(lexer, ltok::RBRACKET)?; @@ -551,8 +551,8 @@ fn plain_expression(lexer: *lex::lexer) (ast::expr | error) = { ltok::NAME => { let id = ident(lexer)?; return match (peek(lexer, ltok::LBRACE)?) { - _: void => id: ast::access_identifier, - _: lex::token => plain_struct(lexer, id)?, + void => id: ast::access_identifier, + lex::token => plain_struct(lexer, id)?, }; }, * => syntaxerr(mkloc(lexer), @@ -568,14 +568,14 @@ fn plain_array(lexer: *lex::lexer) (ast::expr | error) = { let expand = false; for (true) { match (try(lexer, ltok::RBRACKET)?) { - _: lex::token => break, - _: void => void, + lex::token => break, + void => void, }; append(values, alloc(expression(lexer)?)); match (try(lexer, ltok::COMMA, ltok::ELLIPSIS)?) { - _: void => { + void => { want(lexer, ltok::RBRACKET)?; break; }, @@ -650,7 +650,7 @@ fn struct_field( const tok = match (try(lexer, ltok::COLON, ltok::DOUBLE_COLON, ltok::EQUAL)?) { tok: lex::token => tok, - _: void => { + void => { let id: ast::ident = alloc([name]); const expr = plain_struct(lexer, id)?; const expr = expr as ast::constant_expr; @@ -703,18 +703,18 @@ fn plain_tuple(lexer: *lex::lexer, ex: ast::expr) (ast::expr | error) = { for (true) { match (try(lexer, ltok::RPAREN)?) { - _: lex::token => break, - _: void => void, + lex::token => break, + void => void, }; append(values, alloc(expression(lexer)?)); match (try(lexer, ltok::COMMA)?) { - _: void => { + void => { want(lexer, ltok::RPAREN)?; break; }, - _: lex::token => void, + lex::token => void, }; }; @@ -724,7 +724,7 @@ fn plain_tuple(lexer: *lex::lexer, ex: ast::expr) (ast::expr | error) = { fn postfix(lexer: *lex::lexer, lvalue: (ast::expr | void)) (ast::expr | error) = { let lvalue = match (lvalue) { - _: void => plain_expression(lexer)?, + void => plain_expression(lexer)?, ex: ast::expr => ex, }; @@ -744,7 +744,7 @@ fn postfix(lexer: *lex::lexer, lvalue: (ast::expr | void)) (ast::expr | error) = }, * => abort(), }, - _: void => return lvalue, + void => return lvalue, }); }; @@ -754,7 +754,7 @@ fn postfix_dot(lexer: *lex::lexer, lvalue: ast::expr) (ast::expr | error) = { object = alloc(lvalue), field = tok.1 as str, }, - _: void => { + void => { let con = constant(lexer)?; let val = con as ast::constant_expr; synassert(mkloc(lexer), val is lex::value, @@ -859,7 +859,7 @@ fn match_expr(lexer: *lex::lexer) (ast::expr | error) = { let default: nullable *ast::expr = null; for (true) { match (try(lexer, ltok::TIMES)?) { - _: void => append(cases, match_case(lexer)?), + void => append(cases, match_case(lexer)?), t: lex::token => { want(lexer, ltok::CASE)?; if (default != null) { @@ -870,15 +870,15 @@ fn match_expr(lexer: *lex::lexer) (ast::expr | error) = { }; match (try(lexer, ltok::COMMA)?) { - _: void => { + void => { want(lexer, ltok::RBRACE)?; break; }, - _: lex::token => void, + lex::token => void, }; match (try(lexer, ltok::RBRACE)?) { - _: void => void, - _: lex::token => break, + void => void, + lex::token => break, }; }; @@ -893,7 +893,7 @@ fn unarithm(lexer: *lex::lexer) (ast::expr | error) = { const tok = match (try(lexer, ltok::PLUS, ltok::MINUS, ltok::BNOT, ltok::LNOT, ltok::TIMES, ltok::BAND)) { - _: void => return builtin(lexer), + void => return builtin(lexer), tok: lex::token => tok.0, }; const op = switch (tok) { diff --git a/hare/parse/ident.ha b/hare/parse/ident.ha @@ -11,12 +11,12 @@ fn ident_trailing(lexer: *lex::lexer) ((ast::ident, bool) | error) = { for (true) { let name = match (try(lexer, ltok::NAME)?) { t: lex::token => t.1 as str, - _: void => return (ident: ast::ident, true), + void => return (ident: ast::ident, true), }; append(ident, name); z += len(name); match (try(lexer, ltok::DOUBLE_COLON)?) { - _: void => break, + void => break, * => void, // Grab the next ident }; z += 1; diff --git a/hare/parse/import.ha b/hare/parse/import.ha @@ -8,7 +8,7 @@ fn name_list(lexer: *lex::lexer) ([]str | error) = { append(names, want(lexer, ltok::NAME)?.1 as str); switch (want(lexer, ltok::COMMA, ltok::RBRACE)?.0) { ltok::COMMA => match (try(lexer, ltok::RBRACE)?) { - _: void => void, + void => void, * => return names, }, ltok::RBRACE => return names, @@ -23,7 +23,7 @@ export fn imports(lexer: *lex::lexer) ([]ast::import | error) = { let imports: []ast::import = []; for (true) { match (try(lexer, ltok::USE)?) { - _: void => break, + void => break, * => void, }; diff --git a/hare/parse/type.ha b/hare/parse/type.ha @@ -10,8 +10,8 @@ fn prototype(lexer: *lex::lexer) (ast::func_type | error) = { for (try(lexer, ltok::RPAREN)? is void) { let loc = mkloc(lexer); match (try(lexer, ltok::ELLIPSIS)?) { - _: void => void, - _: lex::token => { + void => void, + lex::token => { synassert(loc, len(params) > 0, "Expected at least one non-variadic parameter for C-style variadism")?; variadism = ast::variadism::C; @@ -21,8 +21,8 @@ fn prototype(lexer: *lex::lexer) (ast::func_type | error) = { }, }; let name = match (try(lexer, ltok::UNDERSCORE)?) { - _: void => want(lexer, ltok::NAME)?.1 as str, - _: lex::token => "", + void => want(lexer, ltok::NAME)?.1 as str, + lex::token => "", }; want(lexer, ltok::COLON)?; append(params, ast::func_param { @@ -31,8 +31,8 @@ fn prototype(lexer: *lex::lexer) (ast::func_type | error) = { _type = alloc(_type(lexer)?), }); match (try(lexer, ltok::ELLIPSIS)?) { - _: void => void, - _: lex::token => { + void => void, + lex::token => { variadism = ast::variadism::HARE; try(lexer, ltok::COMMA)?; want(lexer, ltok::RPAREN)?; @@ -40,11 +40,11 @@ fn prototype(lexer: *lex::lexer) (ast::func_type | error) = { }, }; match (try(lexer, ltok::COMMA)?) { - _: void => { + void => { want(lexer, ltok::RPAREN)?; break; }, - _: lex::token => void, + lex::token => void, }; }; let t = _type(lexer)?; @@ -107,7 +107,7 @@ fn primitive_type(lexer: *lex::lexer) (ast::_type | error) = { fn alias_type(lexer: *lex::lexer) (ast::_type | error) = { let loc = mkloc(lexer); let unwrap = match (try(lexer, ltok::ELLIPSIS)?) { - _: void => false, + void => false, * => true, }; return ast::_type { @@ -123,7 +123,7 @@ fn alias_type(lexer: *lex::lexer) (ast::_type | error) = { fn pointer_type(lexer: *lex::lexer) (ast::_type | error) = { let loc = mkloc(lexer); let flags = match (try(lexer, ltok::NULLABLE)?) { - _: void => 0: ast::pointer_flags, + void => 0: ast::pointer_flags, * => ast::pointer_flags::NULLABLE, }; want(lexer, ltok::TIMES)?; @@ -144,11 +144,11 @@ fn tagged_type(lexer: *lex::lexer, first: ast::_type) (ast::_type | error) = { for (try(lexer, ltok::RPAREN)? is void) { append(tagged, alloc(_type(lexer)?)); match (try(lexer, ltok::BOR)?) { - _: void => { + void => { want(lexer, ltok::RPAREN)?; break; }, - _: lex::token => void, + lex::token => void, }; }; return ast::_type { @@ -165,11 +165,11 @@ fn tuple_type(lexer: *lex::lexer, first: ast::_type) (ast::_type | error) = { for (try(lexer, ltok::RPAREN)? is void) { append(tuple, alloc(_type(lexer)?)); match (try(lexer, ltok::COMMA)?) { - _: void => { + void => { want(lexer, ltok::RPAREN)?; break; }, - _: lex::token => void, + lex::token => void, }; }; return ast::_type { @@ -182,7 +182,7 @@ fn tuple_type(lexer: *lex::lexer, first: ast::_type) (ast::_type | error) = { fn fn_type(lexer: *lex::lexer) (ast::_type | error) = { let loc = mkloc(lexer); let attrs = match (try(lexer, ltok::ATTR_NORETURN)?) { - _: void => 0: ast::func_attrs, + void => 0: ast::func_attrs, * => ast::func_attrs::NORETURN, }; want(lexer, ltok::FN)?; @@ -208,8 +208,8 @@ fn struct_union_type(lexer: *lex::lexer) (ast::_type | error) = { }; let offs: nullable *ast::expr = match (try(lexer, ltok::ATTR_OFFSET)?) { - _: void => null, - _: lex::token => { + void => null, + lex::token => { want(lexer, ltok::LPAREN)?; let ex = expression(lexer)?; want(lexer, ltok::RPAREN)?; @@ -269,7 +269,7 @@ fn struct_embed_or_field( let name = want(lexer, ltok::NAME)?; let id: ast::ident = match (try(lexer, ltok::COLON, ltok::DOUBLE_COLON)?) { - _: void => alloc([name.1 as str]), + void => alloc([name.1 as str]), tok: lex::token => switch (tok.0) { ltok::COLON => { let field = ast::struct_field { @@ -301,7 +301,7 @@ fn array_slice_type(lexer: *lex::lexer) (ast::_type | error) = { let length = match (try(lexer, ltok::UNDERSCORE, ltok::TIMES, ltok::RBRACKET)?) { - _: void => alloc(expression(lexer)?), + void => alloc(expression(lexer)?), tok: lex::token => switch (tok.0) { ltok::UNDERSCORE => ast::len_contextual, ltok::TIMES => ast::len_unbounded, @@ -311,7 +311,7 @@ fn array_slice_type(lexer: *lex::lexer) (ast::_type | error) = { }; match (length) { - _: ast::len_slice => void, + ast::len_slice => void, * => want(lexer, ltok::RBRACKET)?, }; @@ -329,12 +329,12 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = { let start = want(lexer, ltok::ENUM)?; const storage = match (try(lexer, ltok::LBRACE)?) { - _: void => { + void => { let storage = integer_type(lexer)?; want(lexer, ltok::LBRACE)?; storage; }, - _: lex::token => builtin_type::INT, + lex::token => builtin_type::INT, }; let membs: []ast::enum_field = []; @@ -376,7 +376,7 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = { // Parses a type, e.g. '[]int'. export fn _type(lexer: *lex::lexer) (ast::_type | error) = { let flags: ast::type_flags = match (try(lexer, ltok::CONST)?) { - _: void => 0, + void => 0, * => ast::type_flags::CONST, }; let tok = peek(lexer)? as lex::token; @@ -409,7 +409,7 @@ export fn _type(lexer: *lex::lexer) (ast::_type | error) = { }; match (try(lexer, ltok::LNOT)?) { - _: void => void, + void => void, * => flags |= ast::type_flags::ERROR, }; diff --git a/hare/unparse/decl.ha b/hare/unparse/decl.ha @@ -77,7 +77,7 @@ export fn decl(out: *io::stream, d: ast::decl) (size | io::error) = { n += prototype(out, 0, f.prototype._type as ast::func_type)?; match (f.body) { - _: void => void, + void => void, e: ast::expr => { n += fmt::fprint(out, " = ")?; n += expr(out, 0, e)?; diff --git a/hare/unparse/expr.ha b/hare/unparse/expr.ha @@ -82,7 +82,7 @@ export fn expr( m: *ast::expr => { let z = 0z; match (e.cond) { - _: *ast::expr => { + *ast::expr => { z += fmt::fprint(out, ", ")?; }, null => void, @@ -100,7 +100,7 @@ export fn expr( }; z += expr(out, indent, *e.object)?; const op = match (e.op) { - _: void => "=", + void => "=", op: ast::binarithm_op => switch (op) { ast::binarithm_op::BAND => "&=", ast::binarithm_op::BOR => "|=", @@ -308,11 +308,11 @@ fn constant( e: ast::constant_expr, ) (size | io::error) = { return match (e) { - _: void => fmt::fprint(out, "void"), - _: ast::_null => fmt::fprint(out, "null"), + void => fmt::fprint(out, "void"), + ast::_null => fmt::fprint(out, "null"), b: bool => fmt::fprint(out, b), v: lex::value => fmt::fprint(out, match (v) { - _: void => abort(), + void => abort(), v: (i64 | u64 | f64) => v, // TODO: Escape these: s: str => return fmt::fprintf(out, "\"{}\"", s), diff --git a/hare/unparse/type.ha b/hare/unparse/type.ha @@ -157,9 +157,9 @@ export fn _type( l: ast::list_type => { n += fmt::fprint(out, "[")?; n += match (l.length) { - _: ast::len_slice => 0, - _: ast::len_unbounded => fmt::fprint(out, "*")?, - _: ast::len_contextual => fmt::fprint(out, "_")?, + ast::len_slice => 0, + ast::len_unbounded => fmt::fprint(out, "*")?, + ast::len_contextual => fmt::fprint(out, "_")?, e: *ast::expr => expr(out, indent, *e)?, }; n += fmt::fprint(out, "]")?; @@ -172,8 +172,8 @@ export fn _type( n += fmt::fprint(out, "*")?; n += _type(out, indent, *p.referent)?; }, - _: ast::struct_type => n += struct_union_type(out, indent, t)?, - _: ast::union_type => n += struct_union_type(out, indent, t)?, + ast::struct_type => n += struct_union_type(out, indent, t)?, + ast::union_type => n += struct_union_type(out, indent, t)?, t: ast::tagged_type => { n += fmt::fprint(out, "(")?; for (let i = 0z; i < len(t); i += 1) { diff --git a/io/+test/copy.ha b/io/+test/copy.ha @@ -40,7 +40,7 @@ fn strconv::ztos(z: size) str; assert(a.r == 42); assert(b.w == 42); }, - _: error => abort(), + error => abort(), }; close(&a: *stream); close(&b: *stream); @@ -54,7 +54,7 @@ fn strconv::ztos(z: size) str; assert(n == 1337); assert(b.w == 62893); }, - _: error => abort(), + error => abort(), }; close(&a: *stream); close(&b: *stream); @@ -70,7 +70,7 @@ fn strconv::ztos(z: size) str; assert(a.r == 42); assert(b.w == 42); }, - _: error => abort(), + error => abort(), }; close(&a: *stream); close(&b: *stream); @@ -89,7 +89,7 @@ fn strconv::ztos(z: size) str; assert(b.w == 42); assert(b.nwrites > 1); }, - _: error => abort(), + error => abort(), }; close(&a: *stream); close(&b: *stream); diff --git a/io/+test/limit.ha b/io/+test/limit.ha @@ -7,31 +7,31 @@ use errors; let r_stream = limitreader(&source_stream.stream, 20); match (write(r_stream, buf)) { - _: errors::unsupported => void, + errors::unsupported => void, * => abort(), }; match (read(r_stream, buf)) { n: size => assert(n == 15), - _: error => abort(), + error => abort(), }; match (read(r_stream, buf)) { n: size => assert(n == 5), - _: error => abort(), + error => abort(), }; close(r_stream); let w_stream = limitwriter(&source_stream.stream, 20); match (read(w_stream, buf)) { - _: errors::unsupported => void, + errors::unsupported => void, * => abort(), }; match (write(w_stream, buf)) { n: size => assert(n == 15), - _: error => abort(), + error => abort(), }; match (write(w_stream, buf)) { n: size => assert(n == 5), - _: error => abort(), + error => abort(), }; close(w_stream); diff --git a/io/copy.ha b/io/copy.ha @@ -7,7 +7,7 @@ export fn copy(dest: *stream, src: *stream) (error | size) = { null => void, c: *copier => match (c(dest, src)) { err: error => match (err) { - _: errors::unsupported => void, // Use fallback + errors::unsupported => void, // Use fallback * => return err, }, s: size => return s, @@ -23,7 +23,7 @@ export fn copy(dest: *stream, src: *stream) (error | size) = { w += r; i += r; }, - _: EOF => break, + EOF => break, }; }; return w; diff --git a/io/drain.ha b/io/drain.ha @@ -5,7 +5,7 @@ export fn drain(in: *io::stream) ([]u8 | io::error) = { for (true) { match (read(in, buf[..])?) { n: size => append(sink, buf[..n]...), - _: EOF => break, + EOF => break, }; }; return sink; diff --git a/io/tee.ha b/io/tee.ha @@ -23,7 +23,7 @@ fn tee_read(s: *stream, buf: []u8) (size | EOF | error) = { let s = s: *tee_stream; let z = match (read(s.source, buf)) { err: error => return err, - _: EOF => return EOF, + EOF => return EOF, z: size => z, }; for (let n = 0z; n < z) { diff --git a/net/+linux/socket.ha b/net/+linux/socket.ha @@ -40,7 +40,7 @@ export fn connect_unix( ) (*io::stream | io::error) = { let sockaddr = match (unix::to_native(addr)) { a: rt::sockaddr => a, - _: unix::invalid => return errors::unsupported, // path too long + unix::invalid => return errors::unsupported, // path too long }; const sockfd = connect_fd(sockaddr, options...)?; return os::fdopen(sockfd, string(addr), @@ -63,9 +63,9 @@ fn listen_fd( for (let i = 0z; i < len(options); i += 1) { match (options[i]) { - _: reuseaddr => setsockopt(sockfd, rt::SO_REUSEADDR, true)?, - _: reuseport => setsockopt(sockfd, rt::SO_REUSEPORT, true)?, - _: keepalive => setsockopt(sockfd, rt::SO_KEEPALIVE, true)?, + reuseaddr => setsockopt(sockfd, rt::SO_REUSEADDR, true)?, + reuseport => setsockopt(sockfd, rt::SO_REUSEPORT, true)?, + keepalive => setsockopt(sockfd, rt::SO_KEEPALIVE, true)?, b: backlog => bk = b, p: portassignment => portout = p, }; @@ -135,7 +135,7 @@ export fn listen_unix( ) (*listener | io::error) = { let sockaddr = match (unix::to_native(addr)) { a: rt::sockaddr => a, - _: unix::invalid => return errors::unsupported, // path too long + unix::invalid => return errors::unsupported, // path too long }; let sockfd = listen_fd(sockaddr, options...)?; return alloc(stream_listener { diff --git a/net/+linux/util.ha b/net/+linux/util.ha @@ -60,7 +60,7 @@ fn from_native(addr: rt::sockaddr) (ip::addr | unix::addr) = { export fn peeraddr(stream: *io::stream) ((ip::addr, u16) | void) = { let fd = match (os::streamfd(stream, true)) { fd: int => fd, - _: void => return, + void => return, }; let sn = rt::sockaddr {...}; let sz = size(rt::sockaddr): u32; diff --git a/net/ip/ip.ha b/net/ip/ip.ha @@ -87,7 +87,7 @@ fn parsev6(st: str) (addr6 | invalid) = { for (i < 16) { let s = match (strings::next_token(&tok)) { s: str => s, - _: void => break, + void => break, }; if (s == "") { if (ells != -1) { @@ -210,8 +210,8 @@ fn fillmask(mask: []u8, val: u8) void = { // Returns an addr representing a netmask fn cidrmask(addr: addr, val: u8) (addr | invalid) = { let a_len: u8 = match (addr) { - _: addr4 => 4, - _: addr6 => 16, + addr4 => 4, + addr6 => 16, }; if (val > 8 * a_len) @@ -280,7 +280,7 @@ fn fmtmask(s: *io::stream, mask: addr) (io::error | size) = { match (masklen(slice)) { // format as hex, if zero runs are not contiguous // (like golang does) - _: void => { + void => { for (let i = 0z; i < len(slice); i += 1) { ret += fmt::fprintf(s, "{:x}", slice[i])?; }; @@ -322,6 +322,6 @@ export fn string(item: (...addr | subnet)) str = { fn wanttoken(tok: *strings::tokenizer) (str | invalid) = { return match (strings::next_token(tok)) { s: str => s, - _: void => invalid + void => invalid }; }; diff --git a/os/+linux/dirfdfs.ha b/os/+linux/dirfdfs.ha @@ -209,7 +209,7 @@ fn fs_remove(fs: *fs::fs, path: str) (void | fs::error) = { let fs = fs: *os_filesystem; match (rt::unlinkat(fs.dirfd, path, 0)) { err: rt::errno => return errno_to_fs(err), - _: void => void, + void => void, }; }; @@ -218,7 +218,7 @@ fn fs_stat(fs: *fs::fs, path: str) (fs::filestat | fs::error) = { let st = rt::st { ... }; match (rt::fstatat(fs.dirfd, path, &st, rt::AT_SYMLINK_NOFOLLOW)) { err: rt::errno => return errno_to_fs(err), - _: void => void, + void => void, }; return fs::filestat { mask = fs::stat_mask::UID @@ -268,7 +268,7 @@ fn fs_rmdir(fs: *fs::fs, path: str) (void | fs::error) = { let fs = fs: *os_filesystem; match (rt::unlinkat(fs.dirfd, path, rt::AT_REMOVEDIR)) { err: rt::errno => return errno_to_fs(err), - _: void => void, + void => void, }; }; @@ -276,7 +276,7 @@ fn fs_mkdir(fs: *fs::fs, path: str) (void | fs::error) = { let fs = fs: *os_filesystem; return match (rt::mkdirat(fs.dirfd, path, 0o755)) { err: rt::errno => errno_to_fs(err), - _: void => void, + void => void, }; }; @@ -284,7 +284,7 @@ fn fs_chmod(fs: *fs::fs, path: str, mode: fs::mode) (void | fs::error) = { let fs = fs: *os_filesystem; return match (rt::fchmodat(fs.dirfd, path, mode: uint)) { err: rt::errno => return errno_to_fs(err), - _: void => void, + void => void, }; }; @@ -292,7 +292,7 @@ fn fs_chown(fs: *fs::fs, path: str, uid: uint, gid: uint) (void | fs::error) = { let fs = fs: *os_filesystem; return match (rt::fchownat(fs.dirfd, path, uid, gid)) { err: rt::errno => return errno_to_fs(err), - _: void => void, + void => void, }; }; @@ -315,13 +315,13 @@ fn fs_resolve(fs: *fs::fs, path: str) str = { if (!path::abs(path)) { let iter = path::iter(getcwd()); for (true) match (path::next(&iter)) { - _: void => break, + void => break, p: str => resolve_part(&parts, p), }; }; let iter = path::iter(path); for (true) match (path::next(&iter)) { - _: void => break, + void => break, p: str => resolve_part(&parts, p), }; return path::join(parts...); diff --git a/os/+linux/environ.ha b/os/+linux/environ.ha @@ -38,7 +38,7 @@ export fn getenv(name: const str) (str | void) = { for (let i = 0z; rt::envp[i] != null; i += 1) { const item = rt::envp[i]: *[*]u8; const eq: size = match (bytes::index(item[..], '=': u32: u8)) { - _: void => abort("Environment violates System-V invariants"), + void => abort("Environment violates System-V invariants"), i: size => i, }; if (bytes::equal(name_b, item[..eq])) { @@ -52,7 +52,7 @@ export fn getenv(name: const str) (str | void) = { // unset. export fn tryenv(name: const str, default: str) str = match (getenv(name)) { s: str => s, - _: void => default, + void => default, }; let envp: []str = []; diff --git a/os/+linux/fdstream.ha b/os/+linux/fdstream.ha @@ -56,7 +56,7 @@ fn is_fdstream(s: *io::stream) bool = { export fn streamfd(s: *io::stream, unwrap: bool) (int | void) = { for (unwrap && !is_fdstream(s)) { s = match (io::source(s)) { - _: errors::unsupported => return, + errors::unsupported => return, s: *io::stream => s, }; }; diff --git a/os/+linux/fs.ha b/os/+linux/fs.ha @@ -22,14 +22,14 @@ export fn chdir(target: (*fs::fs | str)) (void | fs::error) = { let fs = fs: *os_filesystem; return match (rt::fchdir(fs.dirfd)) { err: rt::errno => errors::errno(err), - _: void => void, + void => void, }; }, s: str => s, }; return match (rt::chdir(path)) { err: rt::errno => errors::errno(err), - _: void => void, + void => void, }; }; @@ -40,6 +40,6 @@ export fn chdir(target: (*fs::fs | str)) (void | fs::error) = { export fn chroot(target: str) (void | fs::error) = { return match (rt::chroot(target)) { err: rt::errno => errors::errno(err), - _: void => void, + void => void, }; }; diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -24,7 +24,7 @@ export fn cmd(name: str, args: str...) (command | error) = { err: errors::opaque => return nocmd, p: platform_cmd => p, } else match (lookup(name)) { - _: void => return nocmd, + void => return nocmd, p: platform_cmd => p, }, argv = alloc([], len(args) + 1z), @@ -80,7 +80,7 @@ export fn clearenv(cmd: *command) void = { export fn setenv(cmd: *command, key: str, value: str) void = { let iter = strings::iter(key); for (let i = 0z; true; i += 1) match (strings::next(&iter)) { - _: void => break, + void => break, r: rune => if (i == 0) assert(r == '_' || ascii::isalpha(r), "Invalid environment variable") else assert(r == '_' || ascii::isalnum(r), @@ -101,13 +101,13 @@ export fn setenv(cmd: *command, key: str, value: str) void = { fn lookup(name: str) (platform_cmd | void) = { const path = match (os::getenv("PATH")) { - _: void => return, + void => return, s: str => s, }; let tok = strings::tokenize(path, ":"); for (true) { const item = match (strings::next_token(&tok)) { - _: void => break, + void => break, s: str => s, }; let path = strings::concat(item, "/", name); diff --git a/os/exec/exec+linux.ha b/os/exec/exec+linux.ha @@ -55,7 +55,7 @@ fn platform_start(cmd: *command) (errors::opaque | process) = { let pipe: [2]int = [0...]; match (rt::pipe2(&pipe, rt::O_CLOEXEC)) { err: rt::errno => return errors::errno(err), - _: void => void, + void => void, }; match (rt::clone(null, 0, null, null, 0)) { @@ -72,7 +72,7 @@ fn platform_start(cmd: *command) (errors::opaque | process) = { }, }; }, - _: void => { + void => { rt::close(pipe[0])!; let err = platform_exec(cmd); let err = &err.data: *rt::errno; diff --git a/os/exec/types.ha b/os/exec/types.ha @@ -16,7 +16,7 @@ export type error = (nocmd | errors::opaque)!; // Returns a human-readable message for the given error. export fn strerror(err: error) const str = { return match (err) { - _: nocmd => "Command not found", + nocmd => "Command not found", err: errors::opaque => errors::strerror(err), }; }; diff --git a/path/iter.ha b/path/iter.ha @@ -41,7 +41,7 @@ export fn next(iter: *iterator) (str | void) = { }; return match (bytes::next_token(&iter.tok)) { b: []u8 => strings::fromutf8_unsafe(b), - _: void => void, + void => void, }; }; diff --git a/path/names.ha b/path/names.ha @@ -9,7 +9,7 @@ use strings; export fn dirname(path: str) str = { let b = strings::toutf8(path); let i = match (bytes::rindex(b, PATHSEP)) { - _: void => return path, + void => return path, z: size => z, }; if (i == 0) { @@ -33,7 +33,7 @@ export fn dirname(path: str) str = { export fn basename(path: str) str = { let b = strings::toutf8(path); let i = match (bytes::rindex(b, PATHSEP)) { - _: void => return path, + void => return path, z: size => if (z + 1 < len(b)) z + 1z else 0z, }; return strings::fromutf8_unsafe(b[i..]); @@ -62,7 +62,7 @@ export fn extension(p: str) (str, str) = { return (p, ""); }; let i = match (bytes::index(b, '.': u32: u8)) { - _: void => return (p, ""), + void => return (p, ""), z: size => z, }; let e = b[i..]; diff --git a/rt/+linux/segmalloc.ha b/rt/+linux/segmalloc.ha @@ -15,7 +15,7 @@ fn segmalloc(n: size) nullable *void = { fn segfree(p: *void, s: size) void = { match (munmap(p, s)) { err: errno => abort("munmap failed"), - _: void => void, + void => void, }; }; diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -156,7 +156,7 @@ export fn execveat(dirfd: int, path: path, argv: *[*]nullable *const char, path: uintptr: u64, argv: uintptr: u64, envp: uintptr: u64, flags: u64))) { err: errno => err, - _: u64 => abort("unreachable"), + u64 => abort("unreachable"), }; }; @@ -297,7 +297,7 @@ export type fcntl_arg = (void | int | *st_flock | *f_owner_ex | *u64); export fn fcntl(fd: int, cmd: int, arg: fcntl_arg) (int | errno) = { let _fd = fd: u64, _cmd = cmd: u64; return wrap_return(match (arg) { - _: void => syscall2(SYS_fcntl, _fd, _cmd), + void => syscall2(SYS_fcntl, _fd, _cmd), i: int => syscall3(SYS_fcntl, _fd, _cmd, i: u64), l: *st_flock => syscall3(SYS_fcntl, _fd, _cmd, l: uintptr: u64), o: *f_owner_ex => syscall3(SYS_fcntl, _fd, _cmd, o: uintptr: u64), diff --git a/strconv/stou.ha b/strconv/stou.ha @@ -27,12 +27,12 @@ export fn stou64b(s: str, base: uint) (u64 | invalid | overflow) = { let iter = strings::iter(s); for (true) { let r: rune = match (strings::next(&iter)) { - _: void => break, + void => break, r: rune => r, }; let digit = match (rune_to_integer(r)) { - _: void => return (iter.dec.offs - 1): invalid, + void => return (iter.dec.offs - 1): invalid, d: u64 => d, }; diff --git a/strings/index.ha b/strings/index.ha @@ -14,7 +14,7 @@ fn index_rune(s: str, r: rune) (size | void) = { let iter = iter(s); for (let i = 0z; true; i += 1) match (next(&iter)) { n: rune => if (r == n) return i, - _: void => break, + void => break, }; }; diff --git a/strings/iter.ha b/strings/iter.ha @@ -35,12 +35,12 @@ export fn next(iter: *iterator) (rune | void) = { iter.push = void; return r; }, - _: void => void, + void => void, }; return match (utf8::next(&iter.dec)) { r: rune => r, - _: void => void, - _: (utf8::more | utf8::invalid) => + void => void, + (utf8::more | utf8::invalid) => abort("Invalid UTF-8 string (this should not happen)"), }; }; @@ -51,8 +51,8 @@ export fn prev(iter: *iterator) (rune | void) = { assert(iter.push is void); return match (utf8::prev(&iter.dec)) { r: rune => r, - _: void => void, - _: (utf8::more | utf8::invalid) => + void => void, + (utf8::more | utf8::invalid) => abort("Invalid UTF-8 string (this should not happen)"), }; }; @@ -80,7 +80,7 @@ export fn iter_str(iter: *iterator) str = { for (let i = 0z; i < len(expected1); i += 1) { match (next(&s)) { r: rune => assert(r == expected1[i]), - _: void => abort(), + void => abort(), }; }; assert(iter_str(&s) == "にちは"); @@ -89,7 +89,7 @@ export fn iter_str(iter: *iterator) str = { for (let i = 0z; i < len(expected2); i += 1) { match (next(&s)) { r: rune => assert(r == expected2[i]), - _: void => abort(), + void => abort(), }; }; assert(next(&s) is void); @@ -103,7 +103,7 @@ export fn iter_str(iter: *iterator) str = { for (let i = 0z; i< len(expected3); i += 1) { match (prev(&s)) { r: rune => assert(r == expected3[i]), - _: void => abort(), + void => abort(), }; }; assert(prev(&s) is void); diff --git a/strings/sub.ha b/strings/sub.ha @@ -6,7 +6,7 @@ fn utf8_byte_len_bounded(iter: *iterator, end: size) size = { let pos = 0z; for (let i = 0z; i < end; i += 1) { let r: rune = match (strings::next(iter)) { - _: void => break, + void => break, r: rune => r, }; @@ -19,7 +19,7 @@ fn utf8_byte_len_unbounded(iter: *iterator) size = { let pos = 0z; for (true) { let r: rune = match (strings::next(iter)) { - _: void => break, + void => break, r: rune => r, }; @@ -41,7 +41,7 @@ export fn sub(s: str, start: size, end: (size | end)) str = { let starti = utf8_byte_len_bounded(&iter, start); let endi = match (end) { sz: size => starti + utf8_byte_len_bounded(&iter, sz - start), - _: end => starti + utf8_byte_len_unbounded(&iter), + end => starti + utf8_byte_len_unbounded(&iter), }; let bytes = toutf8(s); return fromutf8_unsafe(bytes[starti..endi]); diff --git a/strings/tokenize.ha b/strings/tokenize.ha @@ -19,7 +19,7 @@ export fn tokenize(s: str, delim: str) tokenizer = export fn next_token(s: *tokenizer) (str | void) = { return match (bytes::next_token(s)) { b: []u8 => fromutf8(b), - _: void => void, + void => void, }; }; @@ -27,7 +27,7 @@ export fn next_token(s: *tokenizer) (str | void) = { export fn peek_token(s: *tokenizer) (str | void) = { return match (bytes::peek_token(s)) { b: []u8 => fromutf8(b), - _: void => void, + void => void, }; }; @@ -41,23 +41,23 @@ export fn remaining_tokens(s: *tokenizer) str = { let tok = tokenize("Hello, my name is drew", " "); match (next_token(&tok)) { s: str => assert(s == "Hello,"), - _: void => abort(), + void => abort(), }; match (next_token(&tok)) { s: str => assert(s == "my"), - _: void => abort(), + void => abort(), }; match (peek_token(&tok)) { s: str => assert(s == "name"), - _: void => abort(), + void => abort(), }; match (next_token(&tok)) { s: str => assert(s == "name"), - _: void => abort(), + void => abort(), }; assert(remaining_tokens(&tok) == "is drew"); @@ -90,7 +90,7 @@ export fn splitN(in: str, delim: str, n: size) []str = { for (let i = 0z; i < n - 1z; i += 1) { match (next_token(&tok)) { s: str => append(toks, s), - _: void => return toks, + void => return toks, }; }; append(toks, remaining_tokens(&tok)); diff --git a/temp/+linux.ha b/temp/+linux.ha @@ -67,7 +67,7 @@ export fn dir() str = { let path = path::join(get_tmpdir(), name); match (os::mkdir(path)) { err: fs::error => abort("Could not create temp directory"), - _: void => void, + void => void, }; return path; }; diff --git a/time/+linux/functions.ha b/time/+linux/functions.ha @@ -26,7 +26,7 @@ export fn sleep(n: duration) void = { for (true) { let res = rt::timespec { ... }; match (rt::nanosleep(req, &res)) { - _: void => return, + void => return, err: rt::errno => switch (err) { rt::EINTR => { req = &res; @@ -85,14 +85,14 @@ fn now_vdso(clock: clock, tp: *rt::timespec) (void | rt::errno) = { export fn now(clock: clock) instant = { let tp = rt::timespec { ... }; let err = match (now_vdso(clock, &tp)) { - _: void => return timespec_to_instant(tp), + void => return timespec_to_instant(tp), err: rt::errno => err }; if (err != rt::wrap_errno(rt::ENOSYS)) { abort("Unexpected error from clock_gettime"); }; return match (rt::clock_gettime(clock, &tp)) { - _: void => timespec_to_instant(tp), + void => timespec_to_instant(tp), err: rt::errno => abort("Unexpected error from clock_gettime"), }; }; diff --git a/unix/nice+linux.ha b/unix/nice+linux.ha @@ -17,7 +17,7 @@ export fn nice(inc: int) (void | errors::opaque) = { prio = -20; }; return match (rt::setpriority(rt::PRIO_PROCESS, 0, prio)) { - _: void => void, + void => void, err: rt::errno => errors::errno(err), }; }; diff --git a/unix/passwd/group.ha b/unix/passwd/group.ha @@ -21,7 +21,7 @@ export type grent = struct { export fn nextgr(stream: *io::stream) (grent | io::EOF | io::error | invalid) = { let line = match (bufio::scanline(stream)?) { ln: []u8 => ln, - _: io::EOF => return io::EOF, + io::EOF => return io::EOF, }; let line = match (strings::try_fromutf8(line)) { s: str => s, @@ -69,7 +69,7 @@ export fn getgroup(name: str) (grent | void) = { for (true) { let ent = match (nextgr(file)) { e: grent => e, - _: io::EOF => break, + io::EOF => break, * => abort("Invalid entry in /etc/group"), }; diff --git a/unix/passwd/passwd.ha b/unix/passwd/passwd.ha @@ -26,7 +26,7 @@ export type pwent = struct { // result using [[pwent_finish]]. export fn nextpw(stream: *io::stream) (pwent | io::EOF | io::error | invalid) = { let line = match (bufio::scanline(stream)?) { - _: io::EOF => return io::EOF, + io::EOF => return io::EOF, ln: []u8 => ln, }; let line = match (strings::try_fromutf8(line)) { @@ -86,7 +86,7 @@ export fn getuser(username: str) (pwent | void) = { for (true) { let ent = match (nextpw(file)) { e: pwent => e, - _: io::EOF => break, + io::EOF => break, * => abort("Invalid entry in /etc/passwd"), }; diff --git a/unix/tty/+linux/isatty.ha b/unix/tty/+linux/isatty.ha @@ -6,7 +6,7 @@ use os; export fn isatty(stream: *io::stream) bool = { let fd = match (os::streamfd(stream, true)) { f: int => f, - _: void => return false, + void => return false, }; let wsz = rt::winsize { ... }; return match (rt::ioctl(fd, rt::TIOCGWINSZ, &wsz: *void)) { diff --git a/unix/tty/+linux/open.ha b/unix/tty/+linux/open.ha @@ -7,7 +7,7 @@ use os; export fn open() (*io::stream | error) = { match (os::open("/dev/tty")) { i: *io::stream => return i, - _: fs::error => void, + fs::error => void, }; if (isatty(os::stdout)) { diff --git a/unix/tty/+linux/winsize.ha b/unix/tty/+linux/winsize.ha @@ -8,7 +8,7 @@ use rt; export fn winsize(tty: *io::stream) (ttysize | error) = { let fd = match (os::streamfd(tty, true)) { f: int => f, - _: void => return errors::invalid, + void => return errors::invalid, }; let wsz = rt::winsize { ... }; return match (rt::ioctl(fd, rt::TIOCGWINSZ, &wsz: *void)) { @@ -19,7 +19,7 @@ export fn winsize(tty: *io::stream) (ttysize | error) = { * => abort("unreachable"), }; }, - _: int => ttysize { + int => ttysize { rows = wsz.ws_row, columns = wsz.ws_col, },