summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin@c9x.me>2018-01-28 19:37:32 +0000
committerOri Bernstein <ori@eigenstate.org>2018-01-28 23:58:18 -0800
commit30c662571c4f64f72171cca0efc7bedc59bd53fa (patch)
tree7b6e878c04cb8bf4eee4617e5d163a1cc6db565d
parentfcfba8c44c5ee110b7b5fd86d752fdeec33eeb0b (diff)
downloadmc-30c662571c4f64f72171cca0efc7bedc59bd53fa.tar.gz
Improve error message for mismatched formats.
That caught me many times.
-rw-r--r--lib/std/fmt.myr7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr
index f1e6736..8202ac9 100644
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -180,6 +180,9 @@ const sbfmtv = {sb, fmt, ap -> size
match (state, (b : char))
/* raw bytes */
| (`Copy, '{'):
+ if nfmt > nvarargs
+ die("too few values for fmt\n")
+ ;;
if (fmt[i] : char) == '{'
b = fmt[i++]
sbputb(sb, ('{' : byte))
@@ -238,7 +241,7 @@ const sbfmtv = {sb, fmt, ap -> size
;;
;;
if nfmt != nvarargs
- die("too many params for fmt\n")
+ die("too many values for fmt\n")
;;
-> sb.len
}
@@ -463,7 +466,7 @@ const intparams = {params
| ("x", ""): ip.base = 16
| ("w", wid): ip.padto = getint(wid, "fmt: width must be integer")
| ("p", pad): ip.padfill = decode(pad)
- | (opt, arg):
+ | (opt, arg):
std.write(2, "fmt: ")
std.write(2, opt)
std.write(2, "arg: ")