ref: 4754ca5116714151571639cff957ee0e18a155cc
parent: 269843206145fb19962dded89481391e937ee331
author: Ori Bernstein <[email protected]>
date: Sat Jun 16 18:48:08 EDT 2012
Only try to look up the top level decls for exports.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -419,6 +419,7 @@
static void infernode(Node *n, Type *ret, int *sawret)
{
size_t i;
+ Node *d;
Sym *s;
if (!n)
@@ -427,15 +428,19 @@
case Nfile:
pushstab(n->file.globls);
inferstab(n->file.globls);
- for (i = 0; i < n->file.nstmts; i++)
- infernode(n->file.stmts[i], NULL, sawret);
+ for (i = 0; i < n->file.nstmts; i++) {
+ d = n->file.stmts[i];
+ infernode(d, NULL, sawret);
+ if (d->type == Ndecl) {
+ s = getdcl(file->file.exports, d->decl.sym->name);
+ if (s)
+ unify(n, type(n), s->type);
+ }
+ }
popstab();
break;
case Ndecl:
inferdecl(n);
- s = getdcl(file->file.exports, n->decl.sym->name);
- if (s)
- unify(n, type(n), s->type);
break;
case Nblock:
setsuper(n->block.scope, curstab());