shithub: mc

Download patch

ref: 27ee8d46c38cf5d1960695efc97a36d00dfb1ccb
parent: 1a2c2337f0d396de9433341d799b99882635bcac
author: Ori Bernstein <[email protected]>
date: Fri Feb 21 07:52:59 EST 2014

Merge exported traits.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -793,6 +793,7 @@
     /* export, global version */
     Node *nx, *ng;
     Type *tx, *tg;
+    Trait *trx, *trg;
     Ucon *ux, *ug;
 
     exports = file->file.exports;
@@ -818,6 +819,28 @@
         }
     }
     free(k);
+
+    k = htkeys(exports->tr, &nk);
+    for (i = 0; i < nk; i++) {
+        trx = gettrait(exports, k[i]);
+        nx = k[i];
+        if (!trx->isproto) {
+            trg = gettrait(globls, nx);
+            if (!trg)
+                puttrait(globls, nx, trx);
+            else
+                fatal(nx->line, "Exported type %s already declared on line %d", namestr(nx), tg->line);
+        } else {
+            trg = gettrait(globls, nx);
+            if (trg && !trg->isproto) {
+                *trx = *trg;
+            } else {
+                fatal(nx->line, "Exported type %s not declared", namestr(nx));
+            }
+        }
+    }
+    free(k);
+
 
     k = htkeys(exports->dcl, &nk);
     for (i = 0; i < nk; i++) {