commit a353678c4ba764ee6185458a29439ae330f8cb30
parent 8d044c7753f9ab996610a1239ad207310a5d2d6e
Author: Eyal Sawady <ecs@d2evs.net>
Date: Mon, 19 Apr 2021 19:55:49 -0400
Further fixes to matches
A harec bug was causing these to erroneously be parsed
Diffstat:
30 files changed, 132 insertions(+), 132 deletions(-)
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,
};
};
@@ -163,7 +163,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
@@ -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]);
@@ -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/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/html.ha b/cmd/haredoc/html.ha
@@ -204,7 +204,7 @@ fn type_html(
// other types and highlight more keywords, like const
let z = 0z;
match (_type._type) {
- ast::builtin_type => {
+ _: ast::builtin_type => {
z += fmt::fprint(out, "<span class='type'>")?;
z += html::escape(out, strio::string(buf))?;
z += fmt::fprintf(out, "</span>")?;
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,
};
};
diff --git a/compress/zlib/reader.ha b/compress/zlib/reader.ha
@@ -51,7 +51,7 @@ fn verifysum(s: *reader) (io::EOF | io::error) = {
let hash: [4]u8 = [0...];
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,
};
};
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/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)) {
@@ -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';
@@ -394,7 +394,7 @@ fn prolog(par: *parser) (void | error) = {
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';
@@ -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) {
@@ -454,7 +454,7 @@ fn want(par: *parser, tok: (rune | str | whitespace)...) (bool | error) = {
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/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,
},
},
};
@@ -266,8 +266,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/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),
};
diff --git a/getopt/getopts.ha b/getopt/getopts.ha
@@ -127,7 +127,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;
@@ -235,7 +235,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);
},
diff --git a/hare/ast/type.ha b/hare/ast/type.ha
@@ -142,7 +142,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/lex.ha b/hare/lex/lex.ha
@@ -75,7 +75,7 @@ export fn lex(lex: *lexer) (token | error) = {
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;
@@ -131,7 +131,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,
};
@@ -147,7 +147,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,
};
@@ -155,7 +155,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,
};
@@ -180,7 +180,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 {
@@ -206,7 +206,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 \"\'\""),
@@ -225,7 +225,7 @@ fn lex_name(lex: *lexer, loc: location, keyword: bool) (token | error) = {
};
for (true) match (next(lex)?) {
- io::EOF => break,
+ _: io::EOF => break,
r: rune => {
if (!is_name(r, true)) {
unget(lex, r);
@@ -255,7 +255,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);
@@ -264,7 +264,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;
@@ -279,13 +279,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,
};
};
@@ -294,7 +294,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) {
@@ -317,7 +317,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) {
@@ -327,7 +327,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)) {
@@ -376,8 +376,8 @@ 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"),
};
@@ -408,8 +408,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,
@@ -431,8 +431,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"),
};
@@ -448,14 +448,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) {
@@ -463,21 +463,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) {
@@ -490,7 +490,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) {
@@ -502,14 +502,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) {
@@ -517,7 +517,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) {
@@ -525,7 +525,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) {
@@ -533,7 +533,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"),
};
@@ -543,7 +543,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),
@@ -563,7 +563,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) {
@@ -571,7 +571,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;
@@ -588,7 +588,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) {
@@ -596,7 +596,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;
@@ -614,7 +614,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) {
@@ -622,7 +622,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;
diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha
@@ -69,7 +69,7 @@ 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,
diff --git a/hare/module/types.ha b/hare/module/types.ha
@@ -71,7 +71,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/expr.ha b/hare/parse/expr.ha
@@ -391,7 +391,7 @@ fn control(lexer: *lex::lexer) (ast::expr | error) = {
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,
+ _: lex::token => null: ast::return_expr,
},
};
};
diff --git a/hare/parse/type.ha b/hare/parse/type.ha
@@ -317,7 +317,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)?,
};
@@ -340,7 +340,7 @@ fn enum_type(lexer: *lex::lexer) (ast::_type | error) = {
want(lexer, ltok::LBRACE)?;
storage;
},
- lex::token => builtin_type::INT,
+ _: lex::token => builtin_type::INT,
};
let membs: []ast::enum_field = [];
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,
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,
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/ip/ip.ha b/net/ip/ip.ha
@@ -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)
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/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/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 [[unix::passwd::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"),
};