[PATCH] Improve error message for mistmatched formats.
[Thread Prev] | [Thread Next]
- Subject: [PATCH] Improve error message for mistmatched formats.
- From: Quentin Carbonneaux <quentin@xxxxxx>
- Reply-to: myrddin-dev@xxxxxxxxxxxxxx
- Date: Sun, 28 Jan 2018 19:37:32 +0000
- To: myrddin-dev@xxxxxxxxxxxxxx
That caught me many times. --- lib/std/fmt.myr | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr index f1e67362..22a0c6cd 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: ") -- 2.15.1
Re: [PATCH] Improve error message for mistmatched formats. | Ori Bernstein <ori@xxxxxxxxxxxxxx> |
- Prev by Date: Re: [PATCH] New auto operator.
- Next by Date: Re: [PATCH] Improve error message for mistmatched formats.
- Previous by thread: Re: [PATCH] Cheap enums.
- Next by thread: Re: [PATCH] Improve error message for mistmatched formats.
- Index(es):