ref: 783e13e96fccbb5278f5ab351673d29e20d4bf66
parent: 3805b9556a6ed96cac073dbda26519f3390661ee
parent: 5ec2c38d36f593ebbe4eb0da31b7537455f1f175
author: scharlatan <a.regenfuss@gmx.de>
date: Mon Feb 8 19:08:12 EST 2016
Merge branch 'master' of https://github.com/oridb/mc
--- a/parse/fold.c
+++ b/parse/fold.c
@@ -182,9 +182,12 @@
r = val(n->loc, a / b, exprtype(n));
break;
case Omod:
- /* x%1 = x */
+ /* x%0 = error */
if (isintval(args[1], 0))
- r = args[0];
+ fatal(args[1], "division by zero");
+ /* x%1 = 0 */
+ if (isintval(args[1], 1))
+ r = val(n->loc, 0, exprtype(n));
if (getintlit(args[0], &a) && getintlit(args[1], &b))
r = val(n->loc, a % b, exprtype(n));
break;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -390,9 +390,9 @@
if (debugopt['u']) {
to = tystr(t);
indentf(st->indentdepth, "Freshen %s => %s\n", from, to);
- free(from);
free(to);
}
+ free(from);
return t;
}