shithub: mc

Download patch

ref: d5f2f88064356c362bad8c63153d7543c0141bab
parent: 008529cafa91d5f05b4e3db7db8cd165859acc47
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Aug 10 19:44:45 EDT 2015

Correctly dedup types in traits.

--- a/parse/gram.y
+++ b/parse/gram.y
@@ -205,7 +205,6 @@
         | use {lappend(&file->file.uses, &file->file.nuses, $1);}
         | implstmt {
                 lappend(&file->file.stmts, &file->file.nstmts, $1);
-                putimpl(file->file.globls, $1);
             }
         | traitdef {
                 size_t i;
@@ -329,7 +328,7 @@
             }
         | implstmt {
                 $1->impl.vis = Visexport;
-                putimpl(file->file.globls, $1);
+                lappend(&file->file.stmts, &file->file.nstmts, $1);
             }
         | /* empty */
         ;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1506,9 +1506,9 @@
 static void specializeimpl(Inferstate *st, Node *n)
 {
     Node *dcl, *proto, *name;
+    Type *ty;
     Htab *ht;
     Trait *t;
-    Type *ty;
     size_t i, j;
 
     t = gettrait(curstab(), n->impl.traitname);
@@ -1518,6 +1518,7 @@
 
     dcl = NULL;
     proto = NULL;
+    n->impl.type = tf(st, n->impl.type);
     for (i = 0; i < n->impl.ndecls; i++) {
         /* look up the prototype */
         proto = NULL;
@@ -2090,6 +2091,8 @@
             }
             break;
         case Nimpl:
+            putimpl(curstab(), n);
+            break;
         case Nname:
         case Nuse:
             break;
--- a/parse/node.c
+++ b/parse/node.c
@@ -214,6 +214,7 @@
     return n;
 }
 
+
 Node *mkimplstmt(Srcloc loc, Node *name, Type *t, Node **decls, size_t ndecls)
 {
     Node *n;