ref: 9526e43a51595f081bfa0cc8b63d625ea785ff6d
parent: d534f4ba7940abe04a5e8e12b3b41a86dc0a7107
author: Ori Bernstein <[email protected]>
date: Sun Nov 30 12:42:04 EST 2014
Be stricter about negating booleans. We used to allow non-booleans. This was bad.
--- a/libstd/alloc.myr
+++ b/libstd/alloc.myr
@@ -56,7 +56,7 @@
const Align = 16 /* minimum allocation alignment */
var buckets : bucket[32] /* excessive */
-var initdone : int
+var initdone : bool
type slheader = struct
cap : size /* capacity in bytes */
@@ -217,7 +217,7 @@
for i = 0; i < buckets.len && (Align << i) <= Bktmax; i++
bktinit(&buckets[i], Align << i)
;;
- initdone = 1
+ initdone = true
;;
if (sz <= Bktmax)
@@ -319,7 +319,7 @@
b = s.freehd
s.freehd = b.next
s.nfree--
- if !s.nfree
+ if s.nfree == 0
bkt.slabs = s.next
s.next = Zslab
;;
--- a/libstd/optparse.myr
+++ b/libstd/optparse.myr
@@ -82,7 +82,7 @@
;;
| `Some (false, _):
arg = ""
- if !ctx.curarg.len
+ if ctx.curarg.len != 0
next(ctx)
;;
;;
@@ -92,7 +92,7 @@
}
const optdone = {ctx
- -> !ctx.curarg.len && ctx.finished
+ -> ctx.curarg.len == 0 && ctx.finished
}
const optinfo = {ctx, arg
--- a/libstd/utf.myr
+++ b/libstd/utf.myr
@@ -68,7 +68,7 @@
var c
var tmp
- if !str.len
+ if str.len == 0
/* empty string: no resync needed */
-> (Badchar, str)
;;
--- a/mk/c.mk
+++ b/mk/c.mk
@@ -6,7 +6,7 @@
_LIBINCPATHS=$(addprefix -I, $(dir $(DEPS)))
_LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(DEPS))))
-CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -g
+CFLAGS += -O0 -Wall -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -g
CFLAGS += -MMD -MP -MF ${_DEPSDIR}/$(subst /,-,$*).d
LIB ?= $(INSTLIB)
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1317,13 +1317,12 @@
t = unify(st, n, t, type(st, args[i]));
settype(st, n, t);
if (args[0]->expr.isconst)
- fatal(n, "Attempting to assign constant \"%s\"", ctxstr(st, args[0]));
+ fatal(n, "attempting to assign constant \"%s\"", ctxstr(st, args[0]));
break;
/* operands same type, returning bool */
case Olor: /* @a || @b -> bool */
case Oland: /* @a && @b -> bool */
- case Olnot: /* !@a -> bool */
case Oeq: /* @a == @a -> bool */
case One: /* @a != @a -> bool */
case Ogt: /* @a > @a -> bool */
@@ -1337,6 +1336,12 @@
settype(st, n, mktype(Zloc, Tybool));
break;
+ case Olnot: /* !bool -> bool */
+ infersub(st, n, ret, sawret, &isconst);
+ t = unify(st, n, type(st, args[0]), mktype(Zloc, Tybool));
+ settype(st, n, t);
+ break;
+
/* reach into a type and pull out subtypes */
case Oaddr: /* &@a -> @a* */
infersub(st, n, ret, sawret, &isconst);
@@ -2242,3 +2247,4 @@
typesub(&st, file);
specialize(&st, file);
}
+
--- a/test/encodechar.myr
+++ b/test/encodechar.myr
@@ -15,7 +15,7 @@
while s.len != 0
(c, s) = std.striter(s)
foo = c
- if !std.encode(buf[:std.charlen(c)], c)
+ if std.encode(buf[:std.charlen(c)], c) == 0
std.write(1, "couldn't encode\n")
;;
std.write(1, buf[:std.charlen(c)])