summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6/simp.c2
-rw-r--r--6/typeinfo.c3
-rw-r--r--mi/match.c11
-rw-r--r--parse/type.c4
-rw-r--r--parse/types.def1
-rw-r--r--test/genericrec.myr5
6 files changed, 22 insertions, 4 deletions
diff --git a/6/simp.c b/6/simp.c
index 60610fd..6ee4faa 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -629,6 +629,8 @@ static void matchpattern(Simp *s, Node *pat, Node *val, Type *t, Node *iftrue, N
matchpattern(s, pat, val, uc->etype, iftrue, iffalse);
}
break;
+ case Tygeneric:
+ break;
}
}
diff --git a/6/typeinfo.c b/6/typeinfo.c
index e1d5de9..37449d1 100644
--- a/6/typeinfo.c
+++ b/6/typeinfo.c
@@ -83,7 +83,8 @@ size_t tysize(Type *t)
sz = max(sz, tysize(t->udecls[i]->etype) + Wordsz);
return align(sz, Ptrsz);
break;
- case Tybad: case Tyvar: case Typaram: case Tyunres: case Ntypes:
+ case Tygeneric: case Tybad: case Tyvar:
+ case Typaram: case Tyunres: case Ntypes:
die("Type %s does not have size; why did it get down to here?", tystr(t));
break;
}
diff --git a/mi/match.c b/mi/match.c
index f80e40e..0ba3f2c 100644
--- a/mi/match.c
+++ b/mi/match.c
@@ -43,9 +43,14 @@ void dtdump(Dtree *dt, FILE *f);
* out of memory, etc) long before getting to this code if we actually had that
* many branches of the switch statements anyways.
*/
-static size_t nconstructors(Type *t) { if (!t) return 0; t = tybase(t); switch
-(t->type) { case Tyvoid: return 0; break;
+static size_t nconstructors(Type *t)
+{
+ if (!t)
+ return 0;
+ t = tybase(t);
+ switch (t->type) {
+ case Tyvoid: return 0; break;
case Tybool: return 2; break;
case Tychar: return 0x10ffff; break;
@@ -79,7 +84,7 @@ static size_t nconstructors(Type *t) { if (!t) return 0; t = tybase(t); switch
case Tyunion: return t->nmemb; break;
case Tyslice: return ~0ULL; break;
case Tyvar: case Typaram: case Tyunres: case Tyname:
- case Tybad: case Tyvalist: case Ntypes:
+ case Tybad: case Tyvalist: case Tygeneric: case Ntypes:
die("Invalid constructor type %s in match", tystr(t));
break;
}
diff --git a/parse/type.c b/parse/type.c
index 9550e97..ce15b9b 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -606,6 +606,8 @@ static int tybfmt(char *buf, size_t len, Type *t)
}
p += snprintf(p, end - p, ")");
break;
+ case Tygeneric:
+ break;
case Tystruct: p += fmtstruct(p, end - p, t); break;
case Tyunion: p += fmtunion(p, end - p, t); break;
case Ntypes:
@@ -827,6 +829,8 @@ size_t tyidfmt(char *buf, size_t sz, Type *ty)
for (i = 0; i < ty->nparam; i++)
p += tyidfmt(p, end - p, ty->param[i]);
break;
+ case Tygeneric:
+ break;
}
return p - buf;
}
diff --git a/parse/types.def b/parse/types.def
index 417c171..a079fbd 100644
--- a/parse/types.def
+++ b/parse/types.def
@@ -44,3 +44,4 @@ Ty(Tyvar, NULL)
Ty(Typaram, NULL)
Ty(Tyunres, NULL) /* unresolved */
Ty(Tyname, NULL)
+Ty(Tygeneric, NULL)
diff --git a/test/genericrec.myr b/test/genericrec.myr
index 8dd4855..414c596 100644
--- a/test/genericrec.myr
+++ b/test/genericrec.myr
@@ -8,4 +8,9 @@ type list(@t) = struct
const main = {
var v : list(int)
+ var n
+
+ v.val = 123
+ v.next = std.alloc()
+ v.next.val = 234
}