summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2019-05-21 08:30:02 -0400
committerOri Bernstein <ori@eigenstate.org>2019-06-09 18:02:06 -0700
commit9bf446ab7795f7397bc4fb7ae9e46ce14c3f679c (patch)
tree246f5a34a6e14ebb3112ae0031a463b0da495374 /lib
parentfd333ef7321e70c49b97d9ffb47805fe686e5d05 (diff)
downloadmc-9bf446ab7795f7397bc4fb7ae9e46ce14c3f679c.tar.gz
Fix error message for {} without parameter
Move the nfmt > nvarargs check to where it can detect the imminent bad access.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/fmt.myr8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr
index 6e6ddab..60a9411 100644
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -181,9 +181,6 @@ 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))
@@ -217,8 +214,11 @@ const sbfmtv = {sb, fmt, ap -> size
if startp != nbuf
param[nparam++] = (buf[startp:nbuf], "")
;;
- fmtval(sb, vatype(ap), ap, param[:nparam])
nfmt++
+ if nfmt > nvarargs
+ die("too few values for fmt\n")
+ ;;
+ fmtval(sb, vatype(ap), ap, param[:nparam])
| (`ParamOpt, '\\'):
buf[nbuf++] = fmt[i++]
| (`ParamOpt, chr):