diff options
author | Ori Bernstein <ori@eigenstate.org> | 2014-11-04 21:34:24 -0500 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2014-11-04 21:34:24 -0500 |
commit | 09af6b8f6597c29208b8725b4f67bd7ed6d45e85 (patch) | |
tree | bde47d08349e5512f71c36c5f7d39e19ffd0f4b0 /libstd | |
parent | 3460240b3a7654af5a994d305d8ab440b7fdfd54 (diff) | |
download | mc-09af6b8f6597c29208b8725b4f67bd7ed6d45e85.tar.gz |
Check for exhaustiveness in patterns.
Diffstat (limited to 'libstd')
-rw-r--r-- | libstd/fltfmt.myr | 2 | ||||
-rw-r--r-- | libstd/fmt.myr | 1 | ||||
-rw-r--r-- | libstd/hashfuncs.myr | 3 | ||||
-rw-r--r-- | libstd/resolve.myr | 20 |
4 files changed, 22 insertions, 4 deletions
diff --git a/libstd/fltfmt.myr b/libstd/fltfmt.myr index ce77e2c..9fe07cd 100644 --- a/libstd/fltfmt.myr +++ b/libstd/fltfmt.myr @@ -151,6 +151,7 @@ const dragon4 = {buf, isneg, f, e, p, mode, cutoff bigfree(t) bigfree(u) break + | _: ;; ;; @@ -173,6 +174,7 @@ const dragon4 = {buf, isneg, f, e, p, mode, cutoff bigshli(t, 1) match bigcmp(t, mm) | `Before: low = true + | _: ;; bigfree(t) diff --git a/libstd/fmt.myr b/libstd/fmt.myr index 486b08b..64cd043 100644 --- a/libstd/fmt.myr +++ b/libstd/fmt.myr @@ -196,6 +196,7 @@ const bfmtv = {buf, fmt, ap | '0': (c, fmt) = striter(fmt) padfill = '0' + | _: /* nothing */ ;; if isdigit(c) && padto == 0 /* diff --git a/libstd/hashfuncs.myr b/libstd/hashfuncs.myr index 49aa0e5..8edb439 100644 --- a/libstd/hashfuncs.myr +++ b/libstd/hashfuncs.myr @@ -1,3 +1,4 @@ +use "die.use" use "sleq.use" use "types.use" @@ -78,6 +79,8 @@ const murmurhash2 = {data, seed h ^= (data[0] castto(uint32)) | 1: h ^= (data[0] castto(uint32)) + | 0: /* nothing */ + | _: die("0 < len < 4 must be true") ;; h *= m diff --git a/libstd/resolve.myr b/libstd/resolve.myr index 5653338..3a4fc42 100644 --- a/libstd/resolve.myr +++ b/libstd/resolve.myr @@ -116,6 +116,7 @@ const loadhosts = { /* trim comment */ match strfind(l, "#") | `Some idx: l = l[:idx] + | `None: /* whole line */ ;; match word(l) @@ -123,6 +124,12 @@ const loadhosts = { match ipparse(ip) | `Some addr: addhosts(addr, ip, rest) + | `None: + /* + invalid addresses are ignored: we don't want to break stuff + with invalid or unsupported addresses + */ + ;; | `None: ;; @@ -175,10 +182,12 @@ const loadresolv = { ;; match word(l) - | `Some (cmd, rest): - if sleq(cmd, "nameserver") - addns(rest) - ;; + | `Some ("nameserver", srv): + addns(srv) + | `Some (_, rest): + /* invalid or unrecognized commands */ + | `None: + /* unrecognized lines */ ;; ;; slfree(lines) @@ -191,7 +200,10 @@ const addns = {rest | `Some addr: nameservers = slpush(nameservers, addr) | `None: + /* nothing */ ;; + | `None: + /* nothing */ ;; } |