ref: e285c2cb9e9a0fcdd2c4dce862842b691713e7a0
parent: 76abfd698816b23920c422a0aa8c4947b156b50c
author: Ori Bernstein <[email protected]>
date: Tue Jun 19 08:18:05 EDT 2012
Find the inferred type before checking for members. @$a doesn't have any members, but if it's been unified with a struct, it should.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -599,6 +599,7 @@
Node *memb;
Node *n;
Node **nl;
+ Type *t;
int found;
for (i = 0; i < npostcheck; i++) {
@@ -611,7 +612,8 @@
memb = postcheck[i]->expr.args[1];
found = 0;
- if (type(aggr)->type == Tyslice || type(aggr)->type == Tyarray) {
+ t = tf(type(aggr));
+ if (t->type == Tyslice || t->type == Tyarray) {
if (!strcmp(namestr(memb), "len")) {
constrain(type(n), cstrtab[Tcnum]);
constrain(type(n), cstrtab[Tcint]);
@@ -619,7 +621,9 @@
found = 1;
}
} else {
- nl = aggrmemb(aggr->expr.type, &nn);
+ if (t->type == Typtr)
+ t = tf(t->sub[0]);
+ nl = aggrmemb(t, &nn);
for (j = 0; j < nn; j++) {
if (!strcmp(namestr(memb), declname(nl[j]))) {
unify(n, type(n), decltype(nl[j]));