shithub: mc

Download patch

ref: 2ba584cf7da0ce23828e187cf22fcbe02d65f7cc
parent: 090d441a579249de5256c02a49bef1cd21104721
author: Ori Bernstein <[email protected]>
date: Wed Jul 25 19:32:09 EDT 2012

Namespaced names need to be looked up in the correct context.

--- a/parse/pickle.c
+++ b/parse/pickle.c
@@ -476,8 +476,11 @@
             n->block.scope = rdstab(fd);
             n->block.nstmts = rdint(fd);
             n->block.stmts = xalloc(sizeof(Node *)*n->block.nstmts);
+            n->func.scope->super = curstab();
+            pushstab(n->func.scope->super);
             for (i = 0; i < n->block.nstmts; i++)
                 n->block.stmts[i] = unpickle(fd);
+            popstab();
             break;
         case Nlbl:
             n->lbl.name = rdstr(fd);
@@ -501,9 +504,12 @@
             n->func.scope = rdstab(fd);
             n->func.nargs = rdint(fd);
             n->func.args = xalloc(sizeof(Node *)*n->func.nargs);
+            n->func.scope->super = curstab();
+            pushstab(n->func.scope->super);
             for (i = 0; i < n->func.nargs; i++)
                 n->func.args[i] = unpickle(fd);
             n->func.body = unpickle(fd);
+            popstab();
             break;
         case Nnone:
             die("Nnone should not be seen as node type!");
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -291,6 +291,8 @@
 {
     Htab *tsmap;
     Node *d;
+    Node *ns;
+    Stab *st;
 
     assert(n->type == Ndecl);
     assert(n->decl.isgeneric);
@@ -299,7 +301,16 @@
     d = getdcl(file->file.globls, *name);
     if (d)
         return d;
+    /* namespaced names need to be looked up in their correct
+     * context. */
+    if (n->decl.name->name.ns) {
+        ns = mkname(n->line, n->decl.name->name.ns);
+        st = getns(file->file.globls, ns);
+        pushstab(st);
+    }
 
+
+
     tsmap = mkht(tyhash, tyeq);
     fillsubst(tsmap, to, n->decl.type);
 
@@ -311,5 +322,7 @@
 
     putdcl(file->file.globls, d);
     lappend(&file->file.stmts, &file->file.nstmts, d);
+    if (d->decl.name->name.ns)
+        popstab();
     return d;
 }