summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-02-28 22:34:52 -0800
committerOri Bernstein <ori@eigenstate.org>2019-02-28 22:34:52 -0800
commit62bd41784b871d00d347787069cc31f4d5e41f4f (patch)
tree3f360e8fe7354520661be25986bb50a4e2bbbe0a
parentaebfdd24002430894e5223faa56abbd7d9c27115 (diff)
downloadmc-62bd41784b871d00d347787069cc31f4d5e41f4f.tar.gz
Fix type substitution in sizeof.
-rw-r--r--lib/std/alloc.myr2
-rw-r--r--lib/std/extremum.myr2
-rw-r--r--parse/infer.c3
3 files changed, 4 insertions, 3 deletions
diff --git a/lib/std/alloc.myr b/lib/std/alloc.myr
index c3e64f7..f395e2d 100644
--- a/lib/std/alloc.myr
+++ b/lib/std/alloc.myr
@@ -52,7 +52,7 @@ generic alloc = {-> @a#
-> (bytealloc(sizeof(@a)) : @a#)
}
-generic zalloc = {-> @a#
+generic zalloc = {
-> (zbytealloc(sizeof(@a)) : @a#)
}
diff --git a/lib/std/extremum.myr b/lib/std/extremum.myr
index 2c46ae1..175e653 100644
--- a/lib/std/extremum.myr
+++ b/lib/std/extremum.myr
@@ -31,7 +31,7 @@ generic clamp = {a, min, max
;;
}
-generic abs = {a : @a :: numeric @a
+generic abs = {a
if a < (0 : @a)
-> -a
else
diff --git a/parse/infer.c b/parse/infer.c
index 98ab589..61af0a5 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1787,8 +1787,9 @@ inferexpr(Node **np, Type *ret, int *sawret)
delayedcheck(n);
break;
case Osize: /* sizeof(@a) -> size */
- infersub(n, ret, sawret, &isconst);
settype(n, mktylike(n->loc, Tyuint));
+ inferdecl(args[0]);
+ n->expr.isconst = 1;
break;
case Ocall: /* (@a, @b, @c, ... -> @r)(@a, @b, @c, ...) -> @r */
infersub(n, ret, sawret, &isconst);