ref: 323f7cc44629fbac0375236b37c7673434eddb69
parent: 74d50fbf7247fb39c27c673f789c781174d0d653
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Feb 1 17:20:38 EST 2016
Fix type array typedef indexing. We weren't looking at the base appropriately.
--- a/6/simp.c
+++ b/6/simp.c
@@ -723,21 +723,22 @@
{
Node *a, *t, *u, *v, *w; /* temps */
Node *r; /* result */
- Type *ty;
+ Type *ty, *seqty;
size_t sz;
a = rval(s, seq, NULL);
- ty = exprtype(seq)->sub[0];
- if (exprtype(seq)->type == Tyarray) {
+ seqty = tybase(exprtype(seq));
+ ty = seqty->sub[0];
+ if (seqty->type == Tyarray) {
t = addr(s, a, ty);
- w = exprtype(a)->asize;
- } else if (seq->expr.type->type == Tyslice) {
+ w = seqty->asize;
+ } else if (seqty->type == Tyslice) {
t = load(addr(s, a, mktyptr(seq->loc, ty)));
w = slicelen(s, a);
} else {
- die("Can't index type %s\n", tystr(seq->expr.type));
+ die("can't index type %s", tystr(seq->expr.type));
}
- assert(t->expr.type->type == Typtr);
+ assert(exprtype(t)->type == Typtr);
u = rval(s, idx, NULL);
u = ptrsized(s, u);
checkidx(s, Olt, w, u);
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -882,6 +882,7 @@
{
Type *t;
+ a = tybase(a);
t = htget(st->seqbase, a);
if (!t && (a->type == Tyslice || a->type == Tyarray || a->type == Typtr))
t = a->sub[0];
@@ -944,7 +945,7 @@
to = tystr(b);
indentf(st->indentdepth, "Unify %s => %s\n", from, to);
indentf(st->indentdepth + 1, "indexes: %s => %s\n",
- tystr(htget(st->seqbase, a)), tystr(htget(st->seqbase, b)));
+ tystr(htget(st->seqbase, a)), tystr(htget(st->seqbase, b)));
free(from);
free(to);
}