diff options
52 files changed, 161 insertions, 161 deletions
diff --git a/bench/regex-match.myr b/bench/regex-match.myr index 9416212..47c9264 100644 --- a/bench/regex-match.myr +++ b/bench/regex-match.myr @@ -13,7 +13,7 @@ const main = { for i = 0; i < 100; i++ match regex.compile(".*") | `std.Ok r: re = r - | `std.Fail m: std.fatal("couldn't compile regex: %s\n", m) + | `std.Err m: std.fatal("couldn't compile regex: %s\n", m) ;; match regex.exec(re, str) diff --git a/lib/bio/bio.myr b/lib/bio/bio.myr index a6dfd48..d93137f 100644 --- a/lib/bio/bio.myr +++ b/lib/bio/bio.myr @@ -117,7 +117,7 @@ const create = {path, mode, perm const dial = {srv, mode match std.dial(srv) | `std.Ok sock: -> `std.Ok mkfile(sock, mode) - | `std.Fail m: -> `std.Fail m + | `std.Err m: -> `std.Err m ;; } @@ -136,7 +136,7 @@ const sysmode = {mode const sysopen = {path, mode, openmode, perm match std.openmode(path, openmode, (perm : int64)) | `std.Ok fd: -> `std.Ok mkfile(fd, mode) - | `std.Fail e: -> `std.Fail "could not open fd" + | `std.Err e: -> `std.Err "could not open fd" ;; } @@ -232,7 +232,7 @@ const read = {f, dst | `std.Ok n: count += n d = d[n:] - | `std.Fail err: + | `std.Err err: if count == 0 -> `Err errtype(err) else @@ -268,7 +268,7 @@ const seek = {f, off f.rstart = f.rend = 0 match std.seek(f.fd, off, std.Seekset) | `std.Ok ret: -> `std.Ok ret - | `std.Fail e: -> `std.Fail errtype(e) + | `std.Err e: -> `std.Err errtype(e) ;; } @@ -604,7 +604,7 @@ const writebuf = {fd, src | `std.Ok n: count += n src = src[n:] - | `std.Fail e: + | `std.Err e: -> `Err errtype(e) ;; ;; @@ -646,7 +646,7 @@ const fill = {f, min | `std.Ok n: count += n f.rend += n - | `std.Fail e: + | `std.Err e: if count > 0 f.lasterr = e else diff --git a/lib/bio/test/bio-create.myr b/lib/bio/test/bio-create.myr index a15c9f0..7015f6a 100644 --- a/lib/bio/test/bio-create.myr +++ b/lib/bio/test/bio-create.myr @@ -7,7 +7,7 @@ const main = { std.mkdir("tmpout", 0o755); match bio.create("tmpout/test-create", bio.Wr, 0o644) | `std.Ok bio: f = bio - | `std.Fail m: std.fatal("Failed to open file: {}\n", m) + | `std.Err m: std.fatal("Failed to open file: {}\n", m) ;; bio.close(f) } diff --git a/lib/bio/test/bio-delim.myr b/lib/bio/test/bio-delim.myr index 7bb0dcf..139b542 100644 --- a/lib/bio/test/bio-delim.myr +++ b/lib/bio/test/bio-delim.myr @@ -7,7 +7,7 @@ const main = { match bio.open("data/lines", bio.Rd) | `std.Ok bio: f = bio - | `std.Fail m: std.fatal("Unable to open data file: {}\n", m) + | `std.Err m: std.fatal("Unable to open data file: {}\n", m) ;; /* read first line */ diff --git a/lib/bio/test/bio-endianrd.myr b/lib/bio/test/bio-endianrd.myr index 629d9a6..bad5d57 100644 --- a/lib/bio/test/bio-endianrd.myr +++ b/lib/bio/test/bio-endianrd.myr @@ -17,7 +17,7 @@ const main = { /* use the expected write data as read data */ match bio.open("data/bio-endianwr-expected", bio.Rd) | `std.Ok bio: f = bio - | `std.Fail m: std.fatal("Unable to open data file: {}\n", m) + | `std.Err m: std.fatal("Unable to open data file: {}\n", m) ;; /* byte */ diff --git a/lib/bio/test/bio-endianwr.myr b/lib/bio/test/bio-endianwr.myr index 1173bef..c4391f3 100644 --- a/lib/bio/test/bio-endianwr.myr +++ b/lib/bio/test/bio-endianwr.myr @@ -10,7 +10,7 @@ const main = { match bio.create("tmpout/test-endianwr", bio.Wr, 0o644) | `std.Ok bio: f = bio - | `std.Fail m: std.fatal("Unable to open data file: {}\n", m) + | `std.Err m: std.fatal("Unable to open data file: {}\n", m) ;; /* byte */ diff --git a/lib/bio/test/bio-peek.myr b/lib/bio/test/bio-peek.myr index 1f80f06..062464c 100644 --- a/lib/bio/test/bio-peek.myr +++ b/lib/bio/test/bio-peek.myr @@ -8,7 +8,7 @@ const main = { match bio.open("data/datafile", bio.Rd) | `std.Ok bio: f = bio - | `std.Fail m: std.fatal("Unable to open data file: {}", m) + | `std.Err m: std.fatal("Unable to open data file: {}", m) ;; std.assert(peekb(f) == 0x30, "wrong byte value read from datafile") diff --git a/lib/bio/test/bio-read.myr b/lib/bio/test/bio-read.myr index 2112d42..5db9274 100644 --- a/lib/bio/test/bio-read.myr +++ b/lib/bio/test/bio-read.myr @@ -9,7 +9,7 @@ const main = { match bio.open("data/datafile", bio.Rd) | `std.Ok bio: f = bio - | `std.Fail m: std.fatal("Unable to open data file: {}", m) + | `std.Err m: std.fatal("Unable to open data file: {}", m) ;; /* read a 4 byte chunk j*/ diff --git a/lib/bio/test/bio-unitwr.myr b/lib/bio/test/bio-unitwr.myr index 1a78e97..5b66bbb 100644 --- a/lib/bio/test/bio-unitwr.myr +++ b/lib/bio/test/bio-unitwr.myr @@ -5,7 +5,7 @@ const main = { var f match bio.create("tmpout/test-unitwr", bio.Wr, 0o644) | `std.Ok bio: f = bio - | `std.Fail m: std.fatal("Unable to open data file: {}\n", m) + | `std.Err m: std.fatal("Unable to open data file: {}\n", m) ;; bio.putb(f, 42) bio.putc(f, 'ה') diff --git a/lib/bio/test/bio-write.myr b/lib/bio/test/bio-write.myr index 27a3f12..3b682c5 100644 --- a/lib/bio/test/bio-write.myr +++ b/lib/bio/test/bio-write.myr @@ -9,7 +9,7 @@ const main = { match bio.create("tmpout/test-write", bio.Wr, 0o644) | `std.Ok bio: f = bio - | `std.Fail m: std.fatal("Unable to open data file: {}", m) + | `std.Err m: std.fatal("Unable to open data file: {}", m) ;; /* write a 5 byte chunk */ diff --git a/lib/date/parse.myr b/lib/date/parse.myr index 36eb479..80f0b76 100644 --- a/lib/date/parse.myr +++ b/lib/date/parse.myr @@ -53,7 +53,7 @@ const strparse = {f, s, tz, replace d.actual -= (d.tzoff : std.time) match err - | `std.Some e: -> `std.Fail e + | `std.Some e: -> `std.Err e | `std.None: /* no error, we're ok */ ;; diff --git a/lib/date/test/parse.myr b/lib/date/test/parse.myr index a5ffe23..6bc7347 100644 --- a/lib/date/test/parse.myr +++ b/lib/date/test/parse.myr @@ -9,14 +9,14 @@ const main = { | `std.Ok d: std.assert(d.actual == 0, "got wrong date") eq(std.bfmt(buf[:], "{D}", d), "1969-12-31 16:00:00 -0800") - | `std.Fail m: + | `std.Err m: std.fatal("failed to parse date: {}\n", m) ;; match date.parsefmt("%Y-%m-%d", "1969 12 31") | `std.Ok d: std.fatal("should have errored") - | `std.Fail m: + | `std.Err m: eq(std.bfmt(buf[:], "{}", m), "expected separator '-', found ' '") ;; @@ -25,7 +25,7 @@ const main = { | `std.Ok d: std.assert(d.actual == 0, "got wrong date") eq(std.bfmt(buf[:], "{D}", d), "1970-1-01 00:00:00 +0000") - | `std.Fail m: + | `std.Err m: std.fatal("failed to parse date: {}\n", m) ;; @@ -34,7 +34,7 @@ const main = { | `std.Ok d: std.assert(d.actual == -1173675600 * 1_000_000, "wrong timestamp") eq(std.bfmt(buf[:], "{D}", d), "1932-10-23 00:00:00 +0500") - | `std.Fail m: + | `std.Err m: std.fatal("Failed to parse date: {}", m) ;; } diff --git a/lib/date/zoneinfo+posixy.myr b/lib/date/zoneinfo+posixy.myr index 96b95ff..76cb025 100644 --- a/lib/date/zoneinfo+posixy.myr +++ b/lib/date/zoneinfo+posixy.myr @@ -81,7 +81,7 @@ const load = {file /* check magic */ match std.slurp(file) | `std.Ok d: p = d - | `std.Fail m: + | `std.Err m: -> std.zalloc() ;; diff --git a/lib/fileutil/walk.myr b/lib/fileutil/walk.myr index 6af3d1d..75ed5e2 100644 --- a/lib/fileutil/walk.myr +++ b/lib/fileutil/walk.myr @@ -29,7 +29,7 @@ impl iterable walkiter -> byte[:] = if std.fisdir(p) match std.diropen(p) | `std.Ok d: std.slpush(&itp.dirstk, d) - | `std.Fail e: /* ? */ + | `std.Err e: /* ? */ ;; std.slpush(&itp.curdir, p) goto nextfile diff --git a/lib/inifile/parse.myr b/lib/inifile/parse.myr index e5ace94..a44af72 100644 --- a/lib/inifile/parse.myr +++ b/lib/inifile/parse.myr @@ -20,7 +20,7 @@ type parser = struct const load = {path match std.open(path, std.Ordonly) | `std.Ok fd: -> loadf(fd) - | `std.Fail e: -> `std.Fail `Fileerr + | `std.Err e: -> `std.Err `Fileerr ;; } @@ -68,7 +68,7 @@ const loadf = {fd -> `std.Ok ini | `std.Some e: free(ini) - -> `std.Fail e + -> `std.Err e ;; } diff --git a/lib/inifile/test/inifile.myr b/lib/inifile/test/inifile.myr index 98f34ac..4fd894f 100644 --- a/lib/inifile/test/inifile.myr +++ b/lib/inifile/test/inifile.myr @@ -9,7 +9,7 @@ const main = { const failopen = { match inifile.load("figment-of-my-imagination.ini") | `std.Ok _: std.die("found imaginary file\n") - | `std.Fail _: /* as expected */ + | `std.Err _: /* as expected */ ;; } diff --git a/lib/inifile/write.myr b/lib/inifile/write.myr index b8d8e90..deb3ccc 100644 --- a/lib/inifile/write.myr +++ b/lib/inifile/write.myr @@ -12,7 +12,7 @@ const write = {ini, path var ret match bio.create(path, bio.Wr, 0o666) - | `std.Fail e: -> false + | `std.Err e: -> false | `std.Ok f: ret = writeini(f, ini) bio.close(f) diff --git a/lib/regex/compile.myr b/lib/regex/compile.myr index 0b85bd1..5a717ce 100644 --- a/lib/regex/compile.myr +++ b/lib/regex/compile.myr @@ -13,7 +13,7 @@ pkg regex = type parseresult = union `Some ast# `None - `Fail status + `Err status ;; /* Compiles a pattern into a regex */ @@ -26,11 +26,11 @@ const parse = {pat re = std.mk([.pat = pat, .nmatch = 1]) match regexparse(re) - | `None: -> `std.Fail `Incomplete - | `Fail f: -> `std.Fail f + | `None: -> `std.Err `Incomplete + | `Err f: -> `std.Err f | `Some t: if re.pat.len != re.idx - -> `std.Fail `Incomplete + -> `std.Err `Incomplete else -> `std.Ok t ;; @@ -55,8 +55,8 @@ const dbgcompile = {pat, trace /* compiles a pattern into an allocated regex */ const regexcompile = {re, id match regexparse(re) - | `None: -> `std.Fail (`Incomplete) - | `Fail f: -> `std.Fail f + | `None: -> `std.Err (`Incomplete) + | `Err f: -> `std.Err f | `Some t: /* we can bail out of parsing early if we get @@ -64,7 +64,7 @@ const regexcompile = {re, id */ if re.pat.len != re.idx astfree(t) - -> `std.Fail (`Incomplete) + -> `std.Err (`Incomplete) ;; dump(re, t, 0) append(re, `Ilbra 0, t) @@ -75,7 +75,7 @@ const regexcompile = {re, id astfree(t) -> `std.Ok re ;; - -> `std.Fail (`Noimpl) + -> `std.Err (`Noimpl) } const free = {re @@ -476,12 +476,12 @@ const regexparse = {re -> `Some t else astfree(t) - -> `Fail `Incomplete + -> `Err `Incomplete ;; | `None: -> `None - | `Fail st: - -> `Fail st + | `Err st: + -> `Err st ;; } @@ -499,9 +499,9 @@ const altexpr = {re ret = mk(re, `Alt (ret, rhs), idx) | `None: astfree(ret) - -> `Fail (`Incomplete) - | `Fail f: - -> `Fail f + -> `Err (`Incomplete) + | `Err f: + -> `Err f ;; ;; | other: @@ -521,7 +521,7 @@ const catexpr = {re match catexpr(re) | `Some rhs: ret = mk(re, `Cat (t, rhs), idx) - | `Fail f: -> `Fail f + | `Err f: -> `Err f | `None: /* nothing */ ;; | other: @@ -564,9 +564,9 @@ const baseexpr = {re /* lower prec operators */ | '|': -> `None | ')': -> `None - | '*': -> `Fail `Badrep '*' - | '+': -> `Fail `Badrep '+' - | '?': -> `Fail `Badrep '?' + | '*': -> `Err `Badrep '*' + | '+': -> `Err `Badrep '+' + | '?': -> `Err `Badrep '?' | '[': -> chrclass(re) | '^': getc(re); ret = mk(re, `Bol, re.idx) | '$': getc(re); ret = mk(re, `Eol, re.idx) @@ -579,7 +579,7 @@ const baseexpr = {re getc(re) if matchc(re, '?') if !matchc(re, ':') - -> `Fail `Badrep '?' + -> `Err `Badrep '?' ;; nocap = true else @@ -594,15 +594,15 @@ const baseexpr = {re -> `Some mk(re, `Cap (m, s), idx) ;; else - -> `Fail `Unbalanced '(' + -> `Err `Unbalanced '(' ;; - | `None: -> `Fail `Emptyparen - | `Fail st: -> `Fail st + | `None: -> `Err `Emptyparen + | `Err st: -> `Err st ;; | '\\': getc(re) /* consume the slash */ if re.pat.len == re.idx - -> `Fail `Incomplete + -> `Err `Incomplete ;; -> escaped(re) | c: @@ -652,7 +652,7 @@ const escaped = {re | 'n': ret = `Some mk(re, `Chr '\n', idx) | 'b': ret = `Some mk(re, `Chr '\b', idx) | 'u': ret = unichar(re, idx) - | chr: ret = `Fail `Badescape chr + | chr: ret = `Err `Badescape chr ;; -> ret } @@ -661,7 +661,7 @@ const unichar = {re, idx var c if !matchc(re, '{') - -> `Fail `Badescape 'u' + -> `Err `Badescape 'u' ;; c = 0 @@ -670,7 +670,7 @@ const unichar = {re, idx c += std.charval(getc(re), 16) ;; if !matchc(re, '}') - -> `Fail `Badescape 'u' + -> `Err `Badescape 'u' ;; -> `Some mk(re, `Chr c, idx) } @@ -683,7 +683,7 @@ const unicodeclass = {re, neg var idx if re.pat.len == re.idx - -> `Fail (`Incomplete) + -> `Err (`Incomplete) ;; n = 0 idx = re.idx @@ -720,7 +720,7 @@ const unicodeclass = {re, neg elif std.sleq(s, "Zs") || std.sleq(s, "Space_Separator") tab = _ranges.tabblank[:] else - -> `Fail (`Badrange s) + -> `Err (`Badrange s) ;; if !neg t = mk(re, `Ranges std.sldup(tab), idx) @@ -749,7 +749,7 @@ const chrclass = {re ;; if !matchc(re, ']') std.slfree(rl) - -> `Fail `Unbalanced '[' + -> `Err `Unbalanced '[' ;; std.sort(rl, {a, b; diff --git a/lib/regex/redump.myr b/lib/regex/redump.myr index 3f843ea..a69e642 100644 --- a/lib/regex/redump.myr +++ b/lib/regex/redump.myr @@ -28,7 +28,7 @@ const main = {args comp = regex.dbgcompile(cmd.args[0], false) ;; match comp - | `std.Fail m: + | `std.Err m: std.fatal("unable to compile regex: {}\n", m) | `std.Ok re: if cmd.args.len > 1 @@ -48,7 +48,7 @@ const runall = {re, files | `std.Ok fd: dump(re, fd) bio.close(fd) - | `std.Fail m: + | `std.Err m: std.fatal("failed to open {}: {}\n", f, m) ;; ;; diff --git a/lib/std/blat.myr b/lib/std/blat.myr index 803f7ec..c0e2b4b 100644 --- a/lib/std/blat.myr +++ b/lib/std/blat.myr @@ -9,7 +9,7 @@ pkg std = const blat = {path, buf, perm match openmode(path, Ocreat|Owronly, perm) | `Ok fd: -> fblat(fd, buf) - | `Fail e: -> false + | `Err e: -> false ;; } @@ -20,7 +20,7 @@ const fblat = {fd, buf count = 0 while true match write(fd, buf[count:]) - | `Fail e: -> false + | `Err e: -> false | `Ok n: if n == 0 break diff --git a/lib/std/dial+plan9.myr b/lib/std/dial+plan9.myr index 75da35b..65ef984 100644 --- a/lib/std/dial+plan9.myr +++ b/lib/std/dial+plan9.myr @@ -29,7 +29,7 @@ const dial = {str match csdial("/net", proto, rem) | `Ok fd: -> `Ok fd - | `Fail m: + | `Err m: -> csdial("/net.alt", proto, rem) ;; } @@ -42,15 +42,15 @@ const csdial = {netdir, proto, rem /* Try using the connection server */ dir = fmt("{}/cs", netdir) match open(dir, Ordwr) - | `Fail e: + | `Err e: clone = fmt("{}/{}/clone", netdir, proto) match call(clone, rem, netdir) | `Ok fd: std.slfree(clone) -> `Ok fd - | `Fail err: + | `Err err: std.slfree(clone) - -> `Fail "unable to dial without cs" + -> `Err "unable to dial without cs" ;; | `Ok fd: csfd = fd @@ -59,9 +59,9 @@ const csdial = {netdir, proto, rem csaddr = fmt("{}!{}", proto, rem) match write(csfd, csaddr) - | `Fail m: + | `Err m: close(csfd) - -> `Fail "couldn't blah cs" + -> `Err "couldn't blah cs" | `Ok _: /* nothing */ ;; @@ -71,7 +71,7 @@ const csdial = {netdir, proto, rem while true match read(csfd, buf[:]) | `std.Ok _: - | `std.Fail e: + | `std.Err e: break ;; @@ -84,13 +84,13 @@ const csdial = {netdir, proto, rem match call(clone, addr, netdir) | `Ok fd: break - | `Fail _: /* nothing */ + | `Err _: /* nothing */ ;; ;; close(csfd) if ret < 0 - -> `Fail "unable to dial" + -> `Err "unable to dial" ;; -> `Ok ret } @@ -102,16 +102,16 @@ const call : (a : byte[:], b : byte[:], c : byte[:] -> result(fd, byte[:])) = {c var cfd, datafd var c, n - datafd = `Fail "didn't even try to open shit" + datafd = `Err "didn't even try to open shit" c = nsclonestr(clone, netdir) match open(c, Ordwr) - | `Fail e: goto cleanup + | `Err e: goto cleanup | `Ok fd: cfd = fd ;; match read(cfd, namebuf[:]) | `Ok fd: /* nothing */ - | `Fail m: goto cleanup + | `Err m: goto cleanup ;; fput(cfd, "connect {}", addr) name = strstrip(namebuf[:n]) @@ -122,7 +122,7 @@ const call : (a : byte[:], b : byte[:], c : byte[:] -> result(fd, byte[:])) = {c dpath = bfmt(databuf[:], "{}/{}/data", base, name) match open(dpath, Ordwr) | `Ok fd: datafd = `Ok fd - | `Fail m: datafd = `Fail "could not open data" + | `Err m: datafd = `Err "could not open data" ;; :cleanup close(cfd) diff --git a/lib/std/dial+posixy.myr b/lib/std/dial+posixy.myr index 2ee6345..07e8e6e 100644 --- a/lib/std/dial+posixy.myr +++ b/lib/std/dial+posixy.myr @@ -33,8 +33,8 @@ const dial = {ds | `Some ("tcp", str): -> dialsock(sys.Sockstream, str) | `Some ("udp", str): -> dialsock(sys.Sockdgram, str) | `Some ("unix", u): -> dialunix(u) - | `Some (proto, str): -> `Fail "unknown protocol" - | `None: -> `Fail "missing protocol" + | `Some (proto, str): -> `Err "unknown protocol" + | `None: -> `Err "missing protocol" ;; } @@ -47,15 +47,15 @@ const dialsock = {proto, str var err match nameseg(str) - | `None: -> `Fail "required host!port for ip dial" - | `Some ("", _): -> `Fail "empty host" - | `Some (_, ""): -> `Fail "empty port" + | `None: -> `Err "required host!port for ip dial" + | `Some ("", _): -> `Err "empty host" + | `Some (_, ""): -> `Err "empty port" | `Some segs: (hoststr, portstr) = segs ;; match parseport(portstr) | `Some p: port = p - | `None: -> `Fail("invalid port") + | `None: -> `Err("invalid port") ;; match getaddr(hoststr) @@ -67,18 +67,18 @@ const dialsock = {proto, str sa6=[.fam=sys.Afinet6, .addr=bits, .port=hosttonet(port)] sa = (&sa6 : sys.sockaddr#) sz = sizeof(sys.sockaddr_in6) - | `Fail m: - -> `Fail m + | `Err m: + -> `Err m ;; sock = sys.socket(sa.fam, proto, 0) if sock < 0 - -> `Fail "failed to create socket" + -> `Err "failed to create socket" ;; err = sys.connect(sock, sa, sz) if err < 0 sys.close(sock) - -> `Fail "Failed to bind socket" + -> `Err "Failed to bind socket" ;; -> `Ok (sock : fd) @@ -90,16 +90,16 @@ const dialunix = {path sa = [.fam = sys.Afunix] if path.len >= sa.path.len - -> `Fail "path too long" + -> `Err "path too long" ;; sock = sys.socket(sys.Afunix, sys.Sockstream, 0) if sock < 0 - -> `Fail "failed to create socket" + -> `Err "failed to create socket" ;; slcp(sa.path[:path.len], path) if sys.connect(sock, (&sa : sys.sockaddr#), sizeof(sys.sockaddr_un)) < 0 - -> `Fail "failed to bind address" + -> `Err "failed to bind address" ;; -> `Ok (sock : fd) } diff --git a/lib/std/dialparse+posixy.myr b/lib/std/dialparse+posixy.myr index 8d544c6..2d0a695 100644 --- a/lib/std/dialparse+posixy.myr +++ b/lib/std/dialparse+posixy.myr @@ -49,10 +49,10 @@ const getaddr = {addr slfree(hi) else slfree(hi) - -> `Fail "no hosts resolved for addr" + -> `Err "no hosts resolved for addr" ;; - | `Fail m: - -> `Fail "could not get host info" + | `Err m: + -> `Err "could not get host info" ;; ;; -> `Ok ip diff --git a/lib/std/dir+freebsd.myr b/lib/std/dir+freebsd.myr index 1177f2b..8d1c13f 100644 --- a/lib/std/dir+freebsd.myr +++ b/lib/std/dir+freebsd.myr @@ -28,7 +28,7 @@ const diropen = {p fd = sys.open(p, sys.Ordonly | sys.Odir) if fd < 0 - -> `Fail "couldn't open directory" + -> `Err "couldn't open directory" ;; dir = zalloc() dir.fd = fd diff --git a/lib/std/dir+linux.myr b/lib/std/dir+linux.myr index d3aed77..1ce2513 100644 --- a/lib/std/dir+linux.myr +++ b/lib/std/dir+linux.myr @@ -30,7 +30,7 @@ const diropen = {p fd = sys.open(p, sys.Ordonly | sys.Odir) if fd < 0 - -> `Fail "couldn't open directory" + -> `Err "couldn't open directory" ;; dir = zalloc() dir.fd = fd diff --git a/lib/std/dir+openbsd.myr b/lib/std/dir+openbsd.myr index c77d01d..274175d 100644 --- a/lib/std/dir+openbsd.myr +++ b/lib/std/dir+openbsd.myr @@ -28,7 +28,7 @@ const diropen = {p fd = sys.open(p, sys.Ordonly | sys.Odir) if fd < 0 - -> `Fail "couldn't open directory" + -> `Err "couldn't open directory" ;; dir = zalloc() dir.fd = fd diff --git a/lib/std/dir+osx.myr b/lib/std/dir+osx.myr index cc3e1a3..9992787 100644 --- a/lib/std/dir+osx.myr +++ b/lib/std/dir+osx.myr @@ -28,7 +28,7 @@ const diropen = {p fd = sys.open(p, sys.Ordonly | sys.Odir) if fd < 0 - -> `Fail "couldn't open directory" + -> `Err "couldn't open directory" ;; dir = zalloc() dir.fd = fd diff --git a/lib/std/dir+plan9.myr b/lib/std/dir+plan9.myr index 03e77ed..e363662 100644 --- a/lib/std/dir+plan9.myr +++ b/lib/std/dir+plan9.myr @@ -28,7 +28,7 @@ const diropen = {p match open(p, Ordonly) | `Ok f: fd = f - | `Fail e: -> `Fail "couldn't open directory" + | `Err e: -> `Err "couldn't open directory" ;; dir = zalloc() @@ -45,7 +45,7 @@ const dirread = {d match read(d.fd, d.buf[:]) | `Ok 0: -> `None - | `Fail e: + | `Err e: -> `None | `Ok len: d.len = (len : int64) diff --git a/lib/std/env+plan9.myr b/lib/std/env+plan9.myr index 77763de..bc9bd3d 100644 --- a/lib/std/env+plan9.myr +++ b/lib/std/env+plan9.myr @@ -43,7 +43,7 @@ const getenv = {name | `None: s = fmt("/env/{}", name) match std.slurp(s) - | `Fail m: + | `Err m: ret = `None | `Ok data: data = cstrconv(data) diff --git a/lib/std/listen+posixy.myr b/lib/std/listen+posixy.myr index 22ff497..d8a5708 100644 --- a/lib/std/listen+posixy.myr +++ b/lib/std/listen+posixy.myr @@ -26,8 +26,8 @@ const announce = {ds | `Some ("tcp", str): -> announcesock(sys.Sockstream, str) | `Some ("udp", str): -> announcesock(sys.Sockdgram, str) | `Some ("unix", str): -> announceunix(str) - | `Some (proto, str): -> `Fail "unknown protocol" - | `None: -> `Fail "missing protocol" + | `Some (proto, str): -> `Err "unknown protocol" + | `None: -> `Err "missing protocol" ;; } @@ -40,15 +40,15 @@ const announcesock = {proto, str var yes match nameseg(str) - | `None: -> `Fail "required addr!port for ip listen" - | `Some ("", _): -> `Fail "empty host" - | `Some (_, ""): -> `Fail "empty port" + | `None: -> `Err "required addr!port for ip listen" + | `Some ("", _): -> `Err "empty host" + | `Some (_, ""): -> `Err "empty port" | `Some segs: (hoststr, portstr) = segs ;; match parseport(portstr) | `Some p: port = p - | `None: -> `Fail("invalid port") + | `None: -> `Err("invalid port") ;; if std.sleq(hoststr, "*") @@ -65,20 +65,20 @@ const announcesock = {proto, str sa6=[.fam=sys.Afinet6, .addr=bits, .port=hosttonet(port)] sa = (&sa6 : sys.sockaddr#) sz = sizeof(sys.sockaddr_in6) - | `Fail m: - -> `Fail m + | `Err m: + -> `Err m ;; ;; sock = sys.socket(sa.fam, proto, 0) if sock < 0 - -> `Fail "failed to create socket" + -> `Err "failed to create socket" ;; yes = 1 if sys.setsockopt(sock, sys.Solsock, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0 - -> `Fail "failed to set sock opts" + -> `Err "failed to set sock opts" ;; if sys.bind(sock, sa, sz) < 0 - -> `Fail "failed to bind socket" + -> `Err "failed to bind socket" ;; -> `Ok (sock : fd) } @@ -90,21 +90,21 @@ const announceunix = {path sa = [.fam = sys.Afunix] if path.len >= sa.path.len - -> `Fail "path too long" + -> `Err "path too long" ;; slcp(sa.path[:path.len], path) sock = sys.socket(sys.Afunix, sys.Sockstream, 0) if sock < 0 - -> `Fail "failed to create socket" + -> `Err "failed to create socket" ;; yes = 1 if sys.setsockopt(sock, sys.Solsock, sys.Soreuseaddr, (&yes : void#), sizeof(int)) < 0 - -> `Fail "failed to set sock opts" + -> `Err "failed to set sock opts" ;; sys.unlink(path) if sys.bind(sock, (&sa : sys.sockaddr#), sizeof(sys.sockaddr_un)) < 0 - -> `Fail "failed to bind address" + -> `Err "failed to bind address" ;; -> `Ok (sock : fd) @@ -112,7 +112,7 @@ const announceunix = {path const listen = {sock : std.fd -> result(fd, byte[:]) if sys.listen((sock : sys.fd), 10) < 0 - -> `Fail "unable to listen on socket" + -> `Err "unable to listen on socket" ;; -> `Ok (sys.dup((sock : sys.fd)) : fd) } @@ -124,7 +124,7 @@ const accept = {lfd fd = sys.accept((lfd : sys.fd), (0 : sys.sockaddr#), (0 : sys.size#)) if fd < 0 - -> `Fail "unable to accept socket" + -> `Err "unable to accept socket" ;; -> `Ok (fd : fd) } diff --git a/lib/std/mktemp.myr b/lib/std/mktemp.myr index 13de4ea..c5f06c8 100644 --- a/lib/std/mktemp.myr +++ b/lib/std/mktemp.myr @@ -38,17 +38,17 @@ const mktempat = {tmpdir, base, opt, mode for var i = 0; i < Retries; i++ path = randpath(tmpdir, base) match std.openmode(path, opt | Ocreat, mode) - | `Fail e: + | `Err e: if e != Eexist std.slfree(path) - -> `Fail e + -> `Err e ;; | `Ok fd: -> `Ok (fd, path) ;; std.slfree(path) ;; - -> `Fail Eexist + -> `Err Eexist } const mktemppath = {base diff --git a/lib/std/readall.myr b/lib/std/readall.myr index 33fbc0c..68c930e 100644 --- a/lib/std/readall.myr +++ b/lib/std/readall.myr @@ -18,8 +18,8 @@ const readall = {fd, dst break | `Ok n: dst = dst[n:] - | `Fail e: - -> `Fail e + | `Err e: + -> `Err e ;; ;; -> `Ok sz - dst.len diff --git a/lib/std/resolve+posixy.myr b/lib/std/resolve+posixy.myr index c4d6c46..b49a20d 100644 --- a/lib/std/resolve+posixy.myr +++ b/lib/std/resolve+posixy.myr @@ -102,7 +102,7 @@ const loadhosts = { match slurp(Hostfile) | `Ok d: h = d - | `Fail m: -> void + | `Err m: -> void ;; lines = strsplit(h, "\n") @@ -170,7 +170,7 @@ const loadresolv = { lock(netlck) match slurp(Resolvfile) | `Ok d: h = d - | `Fail m: -> void + | `Err m: -> void ;; lines = strsplit(h, "\n") @@ -228,7 +228,7 @@ const dnsresolve = {host, rt var nsrv, r if !valid(host) - -> `Fail (`Badhost) + -> `Err (`Badhost) ;; lock(netlck) for ns in nameservers @@ -241,7 +241,7 @@ const dnsresolve = {host, rt ;; ;; unlock(netlck) - -> `Fail (`Badsrv) + -> `Err (`Badsrv) } const dnsconnect = {ns @@ -318,7 +318,7 @@ const rquery = {srv, id n = sys.read(srv, pktbuf[:]) if n < 0 - -> `Fail `Badconn + -> `Err `Badconn ;; pkt = pktbuf[:n] -> hosts(pkt, id) @@ -333,7 +333,7 @@ const hosts = {pkt, id : uint16 /* parse header */ (v, off) = unpack16(pkt, off) /* id */ if v != id - -> `Fail `Badresp + -> `Err `Badresp ;; (v, off) = unpack16(pkt, off) /* flags */ (q, off) = unpack16(pkt, off) /* qdcount */ diff --git a/lib/std/result.myr b/lib/std/result.myr index e98078a..2afdc54 100644 --- a/lib/std/result.myr +++ b/lib/std/result.myr @@ -1,7 +1,7 @@ pkg std = type result(@a, @b) = union `Ok @a - `Fail @b + `Err @b ;; ;; diff --git a/lib/std/slurp.myr b/lib/std/slurp.myr index c0e417c..a966e4a 100644 --- a/lib/std/slurp.myr +++ b/lib/std/slurp.myr @@ -16,7 +16,7 @@ const Bufstart = 4096 const slurp = {path var sl match open(path, Ordonly) - | `Fail e: -> `Fail e + | `Err e: -> `Err e | `Ok fd: sl = fslurp(fd) close(fd) @@ -41,9 +41,9 @@ const fslurp = {fd bufsz *= 2 slgrow(&buf, bufsz) ;; - | `Fail e: + | `Err e: slfree(buf) - -> `Fail e + -> `Err e ;; ;; die("unreachable") diff --git a/lib/std/spork.myr b/lib/std/spork.myr index d06627c..c149dad 100644 --- a/lib/std/spork.myr +++ b/lib/std/spork.myr @@ -17,11 +17,11 @@ const spork = {cmd /* open up pipes */ err = pipe(&infds) if err != Enone - -> `Fail err + -> `Err err ;; err = pipe(&outfds) if err != Enone - -> `Fail err + -> `Err err ;; match sporkfd(cmd, infds[0], outfds[1]) @@ -30,8 +30,8 @@ const spork = {cmd close(infds[0]); close(outfds[1]); -> `Ok (pid, infds[1], outfds[0]) - | `Fail m: - -> `Fail m + | `Err m: + -> `Err m ;; } @@ -41,23 +41,23 @@ const sporkfd = {cmd, infd, outfd pid = fork() /* error */ if pid < 0 - -> `Fail (pid : errno) + -> `Err (pid : errno) /* child */ elif pid == 0 /* stdin/stdout for our communication. */ match dup2(infd, 0) | `Ok _: /* nothing */ - | `Fail e: -> `Fail e + | `Err e: -> `Err e ;; match dup2(outfd, 1) | `Ok _: /* nothing */ - | `Fail e: -> `Fail e + | `Err e: -> `Err e ;; close(infd) close(outfd) err = execvp(cmd[0], cmd) if err != Enone - -> `Fail err + -> `Err err ;; /* if fork succeeds, we never return */ die("unreachable") diff --git a/lib/std/syswrap+plan9.myr b/lib/std/syswrap+plan9.myr index bbabf22..54d9091 100644 --- a/lib/std/syswrap+plan9.myr +++ b/lib/std/syswrap+plan9.myr @@ -120,7 +120,7 @@ const fmtime = {path var buf : byte[Stringsoff + 512] /* enough space for some strings */ if sys.stat(path, buf[:]) < Stringsoff - -> `Fail Emisc + -> `Err Emisc ;; -> `Ok (getle32(buf[Mtimeoff:Mtimeoff + 8]) : time) } @@ -129,7 +129,7 @@ const fsize = {path var buf : byte[Stringsoff + 512] /* enough space for some strings */ if sys.stat(path, buf[:]) < Stringsoff - -> `Fail Emisc + -> `Err Emisc ;; -> `Ok (getle64(buf[Lengthoff:Lengthoff + 8]) : off) } @@ -246,7 +246,7 @@ const statsz = {buf generic check = {e : @a::(integral, numeric) -> result(@b, errno) if e < 0 - -> `Fail lasterr() + -> `Err lasterr() else -> `Ok (e : @b) ;; diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr index a707a12..2e8474d 100644 --- a/lib/std/syswrap+posixy.myr +++ b/lib/std/syswrap+posixy.myr @@ -175,7 +175,7 @@ const fsize = {path generic check = {e : @a::(integral, numeric) -> result(@b, errno) if e < 0 - -> `Fail (e : errno) + -> `Err (e : errno) else -> `Ok (e : @b) ;; diff --git a/lib/std/try.myr b/lib/std/try.myr index 4fdda95..ade5a19 100644 --- a/lib/std/try.myr +++ b/lib/std/try.myr @@ -12,14 +12,14 @@ pkg std = generic try = {v match v | `Ok x: -> x - | `Fail m: fatal("error: {}\n", m) + | `Err m: fatal("error: {}\n", m) ;; } generic tryv = {v, d match v | `Ok x: -> x - | `Fail m: -> d + | `Err m: -> d ;; } diff --git a/lib/std/writeall.myr b/lib/std/writeall.myr index 9e5ea09..3559c96 100644 --- a/lib/std/writeall.myr +++ b/lib/std/writeall.myr @@ -16,7 +16,7 @@ const writeall = {fd, src match std.write(fd, src) | `Ok n: src = src[n:] - | `Fail e: + | `Err e: -> (sz - src.len, `Some e) ;; ;; diff --git a/lib/thread/spawn+freebsd.myr b/lib/thread/spawn+freebsd.myr index 9bf75e4..71ae87d 100644 --- a/lib/thread/spawn+freebsd.myr +++ b/lib/thread/spawn+freebsd.myr @@ -21,7 +21,7 @@ const spawnstk = {fn, sz stk = getstk(sz) if stk == sys.Mapbad - -> `std.Fail "couldn't get stack" + -> `std.Err "couldn't get stack" ;; tid = -1 /* find top of stack */ @@ -51,7 +51,7 @@ const spawnstk = {fn, sz ], sizeof(sys.thrparam)) if ret < 0 - -> `std.Fail "couldn't spawn thread" + -> `std.Err "couldn't spawn thread" ;; -> `std.Ok (tid : tid) } diff --git a/lib/thread/spawn+linux.myr b/lib/thread/spawn+linux.myr index 20e1de8..524144c 100644 --- a/lib/thread/spawn+linux.myr +++ b/lib/thread/spawn+linux.myr @@ -26,7 +26,7 @@ const spawnstk = {fn, sz stk = getstk(sz) if stk == sys.Mapbad - -> `std.Fail "couldn't get stack" + -> `std.Err "couldn't get stack" ;; tos = (stk : std.intptr) tos -= sizeof(int64) @@ -42,7 +42,7 @@ const spawnstk = {fn, sz &ctid, (0 : byte#), \ (startthread : void#)) if ret < 0 - -> `std.Fail "couldn't spawn thread" + -> `std.Err "couldn't spawn thread" ;; -> `std.Ok (ret : tid) } diff --git a/lib/thread/spawn+openbsd.myr b/lib/thread/spawn+openbsd.myr index f0e1fd4..0ccf759 100644 --- a/lib/thread/spawn+openbsd.myr +++ b/lib/thread/spawn+openbsd.myr @@ -20,7 +20,7 @@ const spawnstk = {fn, sz stk = getstk(sz) if stk == sys.Mapbad - -> `std.Fail "couldn't get stack" + -> `std.Err "couldn't get stack" ;; /* store size */ tos = (stk : std.intptr) @@ -42,7 +42,7 @@ const spawnstk = {fn, sz sizeof(sys.tforkparams), \ (startthread : void#), \ (0 : void#)) < 0 - -> `std.Fail "couldn't spawn thread" + -> `std.Err "couldn't spawn thread" ;; -> `std.Ok (ret : tid) } diff --git a/lib/thread/spawn+osx.myr b/lib/thread/spawn+osx.myr index 0ae8e1b..a301fb8 100644 --- a/lib/thread/spawn+osx.myr +++ b/lib/thread/spawn+osx.myr @@ -46,7 +46,7 @@ const spawnstk = {fn, sz 0) if ret == (-1 : void#) - -> `std.Fail "couldn't spawn thread" + -> `std.Err "couldn't spawn thread" ;; -> `std.Ok (ret : tid) } diff --git a/lib/thread/spawn+plan9.myr b/lib/thread/spawn+plan9.myr index 2c6e856..bb23c2b 100644 --- a/lib/thread/spawn+plan9.myr +++ b/lib/thread/spawn+plan9.myr @@ -12,7 +12,7 @@ const spawn = {fn | 0: fn() std.exit(0) - | -1: -> `std.Fail "unable to spawn thread" + | -1: -> `std.Err "unable to spawn thread" | thr: -> `std.Ok (thr : tid) ;; } diff --git a/mbld/build.myr b/mbld/build.myr index 05628ac..dafb994 100644 --- a/mbld/build.myr +++ b/mbld/build.myr @@ -509,11 +509,11 @@ const isfresh = {src, dst */ match std.fmtime(src) | `std.Ok mt: srcmt = mt - | `std.Fail e: std.fatal("could not stat {}: {}\n", src, e) + | `std.Err e: std.fatal("could not stat {}: {}\n", src, e) ;; match std.fmtime(dst) | `std.Ok mt: dstmt = mt - | `std.Fail e: -> false + | `std.Err e: -> false ;; -> srcmt <= dstmt } diff --git a/mbld/deps.myr b/mbld/deps.myr index ddc3e6b..9ac4d2b 100644 --- a/mbld/deps.myr +++ b/mbld/deps.myr @@ -283,7 +283,7 @@ const opensrc = {b, path ;; match bio.open(path, bio.Rd) - | `std.Fail m: std.fatal("could not open {}: {}\n", path, m) + | `std.Err m: std.fatal("could not open {}: {}\n", path, m) | `std.Ok f: -> f ;; } @@ -391,7 +391,7 @@ const openlib = {lib, incs | `std.Ok file: std.slfree(path) -> file - | `std.Fail m: + | `std.Err m: ;; std.fput(std.Err, "could not find library {}\n", lib) std.fput(std.Err, "search path is:\n") diff --git a/mbld/install.myr b/mbld/install.myr index 8a4f496..2591c59 100644 --- a/mbld/install.myr +++ b/mbld/install.myr @@ -79,7 +79,7 @@ const movefile = {b, rm, dir, file, prefix, perm else std.remove(path) match std.slurp(file) - | `std.Fail m: std.fatal("could not open {} for reading\n", file) + | `std.Err m: std.fatal("could not open {} for reading\n", file) | `std.Ok buf: if std.blat(path, buf, perm) std.put("\t{} => {}\n", file, path) diff --git a/mbld/parse.myr b/mbld/parse.myr index 213cbf4..6e4165a 100644 --- a/mbld/parse.myr +++ b/mbld/parse.myr @@ -104,7 +104,7 @@ const mkparser = {path, dir, basedir, sel ]) match std.slurp(path) | `std.Ok d: p.data = d - | `std.Fail _: std.fatal("could not open '{}'\n", path) + | `std.Err _: std.fatal("could not open '{}'\n", path) ;; p.rest = p.data -> p diff --git a/mbld/subtest.myr b/mbld/subtest.myr index b8cf314..f2a9ad0 100644 --- a/mbld/subtest.myr +++ b/mbld/subtest.myr @@ -50,7 +50,7 @@ const showraw = {f, log match std.read(f, buf[:]) | `std.Ok 0: break | `std.Ok n: std.write(log, buf[:n]) - | `std.Fail e: std.fatal("error writing log: {}\n", e) + | `std.Err e: std.fatal("error writing log: {}\n", e) ;; ;; std.slfree(buf) @@ -84,7 +84,7 @@ const showtests = {f, log, ntests | `std.Some `std.Ok _: endtest(&curtest, &nresults, true, "") continue - | `std.Some `std.Fail m: + | `std.Some `std.Err m: endtest(&curtest, &nresults, false, m) ok = false continue @@ -174,7 +174,7 @@ const testfoot : (ln : byte[:] -> std.option(std.result(void, byte[:]))) = {ln if std.sleq(m[1], "ok") -> `std.Some `std.Ok void else - -> `std.Some `std.Fail std.sldup(m[2]) + -> `std.Some `std.Err std.sldup(m[2]) ;; | `std.None: -> `std.None diff --git a/mbld/test.myr b/mbld/test.myr index e9b8d72..6d436a3 100644 --- a/mbld/test.myr +++ b/mbld/test.myr @@ -161,7 +161,7 @@ const runtest = {b, cmd ;; std.put(":\t") match std.spork(cmd) - | `std.Fail m: + | `std.Err m: std.fatal("\nunable to run test: {}\n", m) | `std.Ok (pid, infd, outfd): log = std.strcat(cmd[0], ".log") diff --git a/test/catfile.myr b/test/catfile.myr index e93349b..3dde925 100644 --- a/test/catfile.myr +++ b/test/catfile.myr @@ -7,7 +7,7 @@ const main = {args : byte[:][:] r = std.slurp("data/catfile-in") match r | `std.Ok dat: std.write(1, dat) - | `std.Fail msg: std.put("Failed to read file: {}\n", msg) + | `std.Err msg: std.put("Failed to read file: {}\n", msg) ;; } |