shithub: mc

Download patch

ref: 62bd41784b871d00d347787069cc31f4d5e41f4f
parent: aebfdd24002430894e5223faa56abbd7d9c27115
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Feb 28 17:34:52 EST 2019

Fix type substitution in sizeof.

--- a/lib/std/alloc.myr
+++ b/lib/std/alloc.myr
@@ -52,7 +52,7 @@
 	-> (bytealloc(sizeof(@a)) : @a#)
 }
 
-generic zalloc = {-> @a#
+generic zalloc = {
 	-> (zbytealloc(sizeof(@a)) : @a#)
 }
 
--- a/lib/std/extremum.myr
+++ b/lib/std/extremum.myr
@@ -31,7 +31,7 @@
 	;;
 }
 
-generic abs = {a : @a :: numeric @a
+generic abs = {a
 	if a < (0 : @a)
 		-> -a
 	else
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1787,8 +1787,9 @@
 		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);