summaryrefslogtreecommitdiff
path: root/mi
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-30 00:48:49 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-30 00:48:49 -0800
commitb778de26a0bcc80aa49f111b8333511511073634 (patch)
tree70f32448b9d6e03ff2acb28d7a14278266c3087c /mi
parent62ea6ad22c399c646e396efe264c8314f14027a3 (diff)
downloadmc-b778de26a0bcc80aa49f111b8333511511073634.tar.gz
Missing a cast to fold to the right type.
The length of an array should always be converted to the type used for indexing. Fixes #31
Diffstat (limited to 'mi')
-rw-r--r--mi/fold.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/mi/fold.c b/mi/fold.c
index f62e440..0625741 100644
--- a/mi/fold.c
+++ b/mi/fold.c
@@ -216,8 +216,10 @@ Node *fold(Node *n, int foldvar)
case Omemb:
t = tybase(exprtype(args[0]));
/* we only fold lengths right now */
- if (t->type == Tyarray && !strcmp(namestr(args[1]), "len"))
- r = t->asize;
+ if (t->type == Tyarray && !strcmp(namestr(args[1]), "len")) {
+ r = mkexpr(n->loc, Ocast, t->asize);
+ r->expr.type = exprtype(n);
+ }
break;
case Oarr:
qsort(n->expr.args, n->expr.nargs, sizeof(Node*), idxcmp);