shithub: mc

Download patch

ref: b6368fd6d548d07f3a94e782579badab14790821
parent: 31dc0048af3102df08524099df2f005f547a2421
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Oct 1 17:56:47 EDT 2015

Don't double-insert namespaces.

    updatens() was changed at some point to register the namespace.
    We don't need to put it in again after we call it, and in fact,
    we crash if we do.

--- a/parse/parse.h
+++ b/parse/parse.h
@@ -476,7 +476,7 @@
 /* stab creation */
 Stab *mkstab(int isfunc);
 
-void putns(Stab *st, Stab *scope);
+void putns(Node *file, Stab *scope);
 void puttype(Stab *st, Node *n, Type *ty);
 void puttrait(Stab *st, Node *n, Trait *trait);
 void putimpl(Stab *st, Node *impl);
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -464,6 +464,7 @@
         dcl->decl.isglobl = 1;
         dcl->decl.isinit = 1;
         dcl->decl.isextern = 1;
+        dcl->decl.ishidden = 1;
         putdcl(file->file.globls, dcl);
     }
     return dcl;
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -292,7 +292,6 @@
         if (!ns) {
             ns = mkstab(0);
             updatens(ns, name->name.ns);
-            putns(file->file.globls, ns);
         }
         st = ns;
     }
@@ -438,13 +437,13 @@
     return NULL;
 }
 
-void putns(Stab *st, Stab *scope)
+void putns(Node *file, Stab *scope)
 {
     Stab *s;
 
     s = getns(file, scope->name);
     if (s)
-        lfatal(Zloc, "Namespace %s already defined", st->name);
+        lfatal(Zloc, "Namespace %s already defined", scope->name);
     htput(file->file.ns, scope->name, scope);
 }
 
--- a/parse/use.c
+++ b/parse/use.c
@@ -706,7 +706,7 @@
     if (!s) {
         s = mkstab(0);
         s->name = strdup(pkg);
-        putns(st, s);
+        putns(file, s);
     }
     return s;
 }