shithub: mc

Download patch

ref: 1c3ed5fc8e69003a0d91a9976afb40bdc6f525ba
parent: 2b13f71e390a91faabcc209f44b1ec20ae0fa4ff
author: Ori Bernstein <[email protected]>
date: Fri Oct 18 09:37:58 EDT 2013

Fix global generic constants.

    Check if we're in a generic before we pop the generic stack,
    and don't add the generics to the blob list, since they're
    virtual blobs.

--- a/6/simp.c
+++ b/6/simp.c
@@ -1492,11 +1492,11 @@
     s.blobs = *blob;
     s.nblobs = *nblob;
 
+    if (dcl->decl.isextern || dcl->decl.isgeneric)
+        return;
     if (isconstfn(dcl)) {
-        if (!dcl->decl.isextern && !dcl->decl.isgeneric) {
-            f = simpfn(&s, name, dcl->decl.init, dcl->decl.isexport);
-            lappend(fn, nfn, f);
-        }
+        f = simpfn(&s, name, dcl->decl.init, dcl->decl.isexport);
+        lappend(fn, nfn, f);
     } else {
         simpconstinit(&s, dcl);
     }
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1240,9 +1240,9 @@
         case Ndecl:
             bind(st, n);
             inferdecl(st, n);
-            unbind(st, n);
             if (type(st, n)->type == Typaram && !st->ingeneric)
                 fatal(n->line, "Generic type %s in non-generic near %s\n", tystr(type(st, n)), ctxstr(st, n));
+            unbind(st, n);
             break;
         case Nblock:
             setsuper(n->block.scope, curstab());
--- /dev/null
+++ b/test/genericval.myr
@@ -1,0 +1,8 @@
+use std
+
+generic Foo : @a::(tctest,tcint,tcnum) = 42
+
+const main = {-> int
+	-> Foo
+}
+
--- a/test/tests
+++ b/test/tests
@@ -64,6 +64,7 @@
 B log-or	E	1
 B str		E	102
 B generic	E	42
+B genericval	E	42
 B trait-builtin	E	42
 B genericcall	E	42
 B generictype	E	0