hare

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

commit 85dffc59ec778ec9011514f0ed98ee69f03e553d
parent aa22c647565bed985b368b6d20e28f2750867dae
Author: wackbyte <wackbyte@protonmail.com>
Date:   Sat,  9 Mar 2024 06:04:39 +0000

follow style guide for void match/switch cases

Replace instances of `case _ => yield;` with `case _ => void;` and reorder
certain cases to align with the style guide.

Diffstat:
Mbufio/scanner.ha | 15+++++----------
Mcrypto/aes/+test/gcm.ha | 3+--
Mcrypto/aes/ctr+test.ha | 3+--
Mcrypto/ec/p256.ha | 3+--
Mcrypto/ecdh/ecdh.ha | 3+--
Mcrypto/rsa/pkcs1.ha | 3+--
Mdebug/dwarf/addr_to_line.ha | 2+-
Mdebug/symbols.ha | 2+-
Mdirs/xdg.ha | 3+--
Mencoding/asn1/+test/decoder_test.ha | 3+--
Mencoding/asn1/charset+test.ha | 6++----
Mencoding/asn1/encoder.ha | 3+--
Mencoding/asn1/strings.ha | 5++---
Mencoding/base32/base32.ha | 9+++------
Mencoding/base64/base64.ha | 10++++------
Mencoding/hex/hex.ha | 6++----
Mencoding/pem/pem.ha | 3+--
Mformat/tar/reader.ha | 3+--
Mfs/fs.ha | 3+--
Mhare/parse/type.ha | 6++----
Mhare/types/store.ha | 6++----
Mhare/unparse/decl.ha | 6++----
Mnet/dial/resolve.ha | 4++--
Mnet/uri/parse.ha | 2+-
Mos/exec/cmd.ha | 3+--
Munix/signal/+freebsd.ha | 6++----
Munix/signal/+linux.ha | 6++----
Munix/signal/+openbsd.ha | 6++----
28 files changed, 47 insertions(+), 86 deletions(-)

diff --git a/bufio/scanner.ha b/bufio/scanner.ha @@ -76,8 +76,7 @@ fn scan_read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = { match (scan_readahead(scan)?) { case io::EOF => return io::EOF; - case size => - yield; + case size => void; }; }; @@ -141,8 +140,7 @@ export fn scan_byte(scan: *scanner) (u8 | io::EOF | io::error) = { match (scan_readahead(scan)?) { case io::EOF => return io::EOF; - case size => - yield; + case size => void; }; }; @@ -165,8 +163,7 @@ export fn scan_bytes( case let ix: size => i = ix; break; - case void => - yield; + case void => void; }; match (scan_readahead(scan)?) { @@ -204,8 +201,7 @@ export fn scan_rune( if (scan.pending == 0) { return io::EOF; }; - case size => - yield; + case size => void; }; }; const sz = utf8::utf8sz(scan.buffer[0])?; @@ -214,8 +210,7 @@ export fn scan_rune( match (scan_readahead(scan)?) { case io::EOF => return utf8::invalid; - case size => - yield; + case size => void; }; }; diff --git a/crypto/aes/+test/gcm.ha b/crypto/aes/+test/gcm.ha @@ -651,8 +651,7 @@ const gcmtestcases: []gcmtestcase = [ let wrongtag: [16]u8 = t.tag; wrongtag[0] += 1; match (cipher::gcm_verify(&gstream, wrongtag)) { - case errors::invalid => - yield; + case errors::invalid => void; case => assert(false); }; diff --git a/crypto/aes/ctr+test.ha b/crypto/aes/ctr+test.ha @@ -409,8 +409,7 @@ fn errwriter(out: io::handle, limit: size, err: io::error) err_stream = { defer io::close(&ctr)!; let n = 0z; match (io::write(&ctr, plain[..64])) { - case errors::again => - yield; + case errors::again => void; case size => assert(false); }; diff --git a/crypto/ec/p256.ha b/crypto/ec/p256.ha @@ -616,8 +616,7 @@ fn p256_to_affine(p: *p256_jacobian) void = { mul_f256(t2, t2, t1); case 63, 253, 255 => mul_f256(t2, t2, p.z); - case => - yield; + case => void; }; }; diff --git a/crypto/ecdh/ecdh.ha b/crypto/ecdh/ecdh.ha @@ -92,10 +92,9 @@ export fn derive( pub: []u8 ) (size | invalidkey) = { match (ec::validate_pointformat(priv.curve, pub)) { - case void => - yield; case ec::invalid => return invalidkey; + case void => void; }; let buf: [ec::MAX_POINTSZ]u8 = [0...]; diff --git a/crypto/rsa/pkcs1.ha b/crypto/rsa/pkcs1.ha @@ -80,8 +80,7 @@ export fn pkcs1_verify( match (pubexp(&pub, actualsig, pubbuf)) { case let e: error => return e; - case void => - yield; + case void => void; }; let expectedsig = pubbuf[..len(sig)]; diff --git a/debug/dwarf/addr_to_line.ha b/debug/dwarf/addr_to_line.ha @@ -49,7 +49,7 @@ export fn addr_to_line( found = true; case DW_AT_comp_dir => comp_dir = field.string; - case => yield; + case => void; }; }; }; diff --git a/debug/symbols.ha b/debug/symbols.ha @@ -98,6 +98,6 @@ fn scan_strtab( match (bytes::index(data, name)) { case let z: size => return z: u64; - case void => yield; + case void => void; }; }; diff --git a/dirs/xdg.ha b/dirs/xdg.ha @@ -32,11 +32,10 @@ fn lookup(prog: str, var: str, default: str) str = { const home = os::getenv("HOME") as str; const path = path::set(&buf, home, default, prog)!; match (os::mkdirs(path, 0o755)) { - case void => - yield; case let err: fs::error => fmt::fatalf("Error creating {}: {}", path, fs::strerror(err)); + case void => void; }; return path; }; diff --git a/encoding/asn1/+test/decoder_test.ha b/encoding/asn1/+test/decoder_test.ha @@ -32,8 +32,7 @@ fn d(i: []u8) decoder = { @fini fn freetdec() void = { match (mem) { - case null => - yield; + case null => void; case let m: *memio::stream => free(m); mem = null; diff --git a/encoding/asn1/charset+test.ha b/encoding/asn1/charset+test.ha @@ -24,8 +24,7 @@ fn print_t61_table(dest: io::handle) void = { match (t61_chardecode([i: u8])) { case insufficient => fmt::fprint(dest, "")!; - case invalid => - yield; + case invalid => void; case let r: rune => if (i > 0xa0 || (ascii::isprint(r) && !ascii::isspace(r))) { fmt::fprint(dest, r)!; @@ -54,8 +53,7 @@ fn print_t61_table(dest: io::handle) void = { match (t61_chardecode([i: u8, j: u8])) { case let r: rune => fmt::fprint(dest, r)!; - case => - yield; + case => void; }; }; fmt::fprintln(dest)!; diff --git a/encoding/asn1/encoder.ha b/encoding/asn1/encoder.ha @@ -414,8 +414,7 @@ export fn encode(e: *encoder) ([]u8 | io::error) = { bytes::zero(buf[t..]); match (e.parent) { - case null => - yield; + case null => void; case let s: *bytewstream => s.e.pos += t; }; diff --git a/encoding/asn1/strings.ha b/encoding/asn1/strings.ha @@ -58,8 +58,7 @@ fn validutf8(buf: []u8) (size | invalid) = { let lastsz = 0z; for (let i = min; i < len(buf); i += 1) { match (utf8::utf8sz(buf[i])) { - case utf8::invalid => - yield; + case utf8::invalid => void; case let s: size => lastsz = s; lastvalid = i; @@ -272,7 +271,7 @@ fn t61_decoder(s: *utf8stream, buf: []u8) (size | io::EOF | io::error) = { }; case insufficient => // leave combining char in in - yield; + void; case invalid => return wrap_err(invalid); }; diff --git a/encoding/base32/base32.ha b/encoding/base32/base32.ha @@ -83,8 +83,7 @@ fn encode_writer( match(s.err) { case let err: io::error => return err; - case void => - yield; + case void => void; }; let l = len(in); let i = 0z; @@ -116,8 +115,7 @@ fn encode_writer( case let err: io::error => s.err = err; return err; - case size => - yield; + case size => void; }; }; // storing leftover bytes @@ -267,8 +265,7 @@ fn decode_reader( match(s.state) { case let err: (io::EOF | io ::error) => return err; - case void => - yield; + case void => void; }; if (len(s.avail) > 0) { n += if (l < len(s.avail)) l else len(s.avail); diff --git a/encoding/base64/base64.ha b/encoding/base64/base64.ha @@ -84,10 +84,10 @@ fn encode_writer( ) (size | io::error) = { let s = s: *encoder; match(s.err) { - case void => yield; case let err: io::error => s.err = void; return err; + case void => void; }; let i = 0z; @@ -107,13 +107,13 @@ fn encode_writer( fillobuf(s); match (writeavail(s)) { - case void => yield; case let e: io::error => if (i == 0) { return e; }; s.err = e; return i; + case void => void; }; }; @@ -157,8 +157,7 @@ fn encode_closer(s: *io::stream) (void | io::error) = { case let e: io::error => s.err = void; return e; - case void => - yield; + case void => void; }; if (s.oavail > 0) { @@ -319,8 +318,7 @@ fn decode_reader( match(s.state) { case let err: (io::EOF | io ::error) => return err; - case void => - yield; + case void => void; }; if (len(s.avail) > 0) { n += if (l < len(s.avail)) l else len(s.avail); diff --git a/encoding/hex/hex.ha b/encoding/hex/hex.ha @@ -38,8 +38,7 @@ fn encode_writer(s: *io::stream, in: const []u8) (size | io::error) = { match(s.err) { case let err: io::error => return err; - case void => - yield; + case void => void; }; let z = 0z; for (let i = 0z; i < len(in); i += 1) { @@ -125,8 +124,7 @@ fn decode_reader(s: *io::stream, out: []u8) (size | io::EOF | io::error) = { match(s.state) { case let err: (io::EOF | io::error) => return err; - case void => - yield; + case void => void; }; static let buf: [os::BUFSZ]u8 = [0...]; let n = len(out) * 2; diff --git a/encoding/pem/pem.ha b/encoding/pem/pem.ha @@ -127,8 +127,7 @@ fn pem_read(st: *io::stream, buf: []u8) (size | io::EOF | io::error) = { match (io::read(&st.b64, buf)?) { case let z: size => return z; - case io::EOF => - yield; + case io::EOF => void; }; const line = match (bufio::read_line(st.b64.in)?) { diff --git a/format/tar/reader.ha b/format/tar/reader.ha @@ -100,8 +100,7 @@ export fn skip(ent: *entry) (void | io::error) = { match (io::seek(ent.src, amt: io::off, io::whence::CUR)) { case io::off => return; - case io::error => - yield; + case io::error => void; }; io::copy(io::empty, ent)?; }; diff --git a/fs/fs.ha b/fs/fs.ha @@ -158,8 +158,7 @@ export fn iter(fs: *fs, path: str) (*iterator | error) = { // Frees state associated with an [[iterator]]. export fn finish(iter: *iterator) void = { match (iter.finish) { - case null => - yield; + case null => void; case let f: *finishfunc => return f(iter); }; diff --git a/hare/parse/type.ha b/hare/parse/type.ha @@ -14,12 +14,11 @@ fn prototype(lexer: *lex::lexer) (ast::func_type | error) = { for (try(lexer, ltok::RPAREN)? is void) { let loc = lex::mkloc(lexer); match (try(lexer, ltok::ELLIPSIS)?) { - case void => - yield void; case lex::token => variadism = ast::variadism::C; want(lexer, ltok::RPAREN)?; break; + case void => void; }; let name_or_type = _type(lexer)?; @@ -43,12 +42,11 @@ fn prototype(lexer: *lex::lexer) (ast::func_type | error) = { }); }; match (try(lexer, ltok::ELLIPSIS)?) { - case void => - yield void; case lex::token => variadism = ast::variadism::HARE; want(lexer, ltok::RPAREN)?; break; + case void => void; }; match (try(lexer, ltok::COMMA)?) { case void => diff --git a/hare/types/store.ha b/hare/types/store.ha @@ -80,10 +80,8 @@ export fn newalias( }, ... })) { - case error => - yield; - case deferred => - yield; + case error => void; + case deferred => void; case let ty: const *_type => let ty = ty: *_type; *ty = atype; diff --git a/hare/unparse/decl.ha b/hare/unparse/decl.ha @@ -37,8 +37,7 @@ export fn decl( for (let i = 0z; i < len(c); i += 1) { n += _ident(&ctx, syn, c[i].ident, synkind::CONSTANT)?; match (c[i]._type) { - case null => - yield; + case null => void; case let ty: *ast::_type => n += syn(&ctx, ":", synkind::PUNCTUATION)?; n += space(&ctx)?; @@ -71,8 +70,7 @@ export fn decl( }; n += _ident(&ctx, syn, g[i].ident, synkind::GLOBAL)?; match (g[i]._type) { - case null => - yield; + case null => void; case let ty: *ast::_type => n += syn(&ctx, ":", synkind::PUNCTUATION)?; n += space(&ctx)?; diff --git a/net/dial/resolve.ha b/net/dial/resolve.ha @@ -28,7 +28,7 @@ export fn splitaddr(addr: str, service: str) ((str, u16) | invalid_address) = { match (strconv::stou16(service)) { case let u: u16 => port = u; - case => yield; + case => void; }; }; return (addr, port); @@ -40,7 +40,7 @@ export fn splitaddr(addr: str, service: str) ((str, u16) | invalid_address) = { match (strconv::stou16(service)) { case let u: u16 => port = u; - case => yield; + case => void; }; case let i: size => const sub = strings::sub(addr, i + 1, strings::end); diff --git a/net/uri/parse.ha b/net/uri/parse.ha @@ -207,7 +207,7 @@ fn parse_authority( if (len(s) == 0) { host = percent_decode(memio::string(&buf)!)?; }; - case => yield; + case => void; }; return (host, port, userinfo); diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -172,8 +172,7 @@ fn lookup_open(name: str) (platform_cmd | void | error) = { // Try to open file directly if (strings::contains(name, "/")) { match (open(name)) { - case (errors::noaccess | errors::noentry) => - yield; + case (errors::noaccess | errors::noentry) => void; case let err: error => return err; case let p: platform_cmd => diff --git a/unix/signal/+freebsd.ha b/unix/signal/+freebsd.ha @@ -49,10 +49,9 @@ export fn handle( ... }; match (rt::sigaction(signum, &new, &old)) { - case int => - yield; case rt::errno => abort("sigaction failed (invalid signal?)"); + case int => void; }; return old; }; @@ -60,10 +59,9 @@ export fn handle( // Restores previous signal behavior following [[handle]]. export fn restore(signum: sig, action: *sigaction) void = { match (rt::sigaction(signum, action: *rt::sigact, null)) { - case int => - yield; case rt::errno => abort("sigaction failed (invalid signal?)"); + case int => void; }; }; diff --git a/unix/signal/+linux.ha b/unix/signal/+linux.ha @@ -53,10 +53,9 @@ export fn handle( ... }; match (rt::sigaction(signum, &new, &old)) { - case int => - yield; case rt::errno => abort("sigaction failed (invalid signal?)"); + case int => void; }; return old; }; @@ -64,10 +63,9 @@ export fn handle( // Restores previous signal behavior following [[handle]]. export fn restore(signum: sig, action: *sigaction) void = { match (rt::sigaction(signum, action: *rt::sigact, null)) { - case int => - yield; case rt::errno => abort("sigaction failed (invalid signal?)"); + case int => void; }; }; diff --git a/unix/signal/+openbsd.ha b/unix/signal/+openbsd.ha @@ -48,10 +48,9 @@ export fn handle( ... }; match (rt::sigaction(signum, &new, &old)) { - case void => - yield; case let err: rt::errno => abort("sigaction failed (invalid signal?)"); + case void => void; }; return old; @@ -60,10 +59,9 @@ export fn handle( // Restores previous signal behavior following [[handle]]. export fn restore(signum: sig, action: *sigaction) void = { match (rt::sigaction(signum, action: *rt::sigact, null)) { - case void => - yield; case rt::errno => abort("sigaction failed (invalid signal?)"); + case void => void; }; };