ref: df187615868a82da67b31b921334449f7db5a868
parent: 226ef2e101258817ee3c41a28846c607d880a69c
author: Ori Bernstein <[email protected]>
date: Thu May 8 10:06:23 EDT 2014
Default the types correctly in specialized functions. If we have @a::(numerical,integral), for example, in a function that is not unfied with any specific numerical,integral type, we need to default it to an int. This does that.
--- a/parse/dump.c
+++ b/parse/dump.c
@@ -114,6 +114,7 @@
{
size_t i;
char *ty;
+ char *tr;
int tid;
char buf[1024];
@@ -138,8 +139,11 @@
outnode(n->file.stmts[i], fd, depth + 1);
break;
case Ndecl:
+ tr = "";
+ if (n->decl.trait)
+ tr = namestr(n->decl.trait->name);
fprintf(fd, "(did = %zd, trait=%s, isconst = %d, isgeneric = %d, isextern = %d, vis = %d)\n",
- n->decl.did, namestr(n->decl.trait->name), n->decl.isconst, n->decl.isgeneric, n->decl.isextern, n->decl.vis);
+ n->decl.did, tr, n->decl.isconst, n->decl.isgeneric, n->decl.isextern, n->decl.vis);
outsym(n, fd, depth + 1);
outnode(n->decl.init, fd, depth + 1);
break;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -2033,6 +2033,10 @@
d = specializedcl(st->genericdecls[i], st->specializations[i]->expr.type, &name);
st->specializations[i]->expr.args[0] = name;
st->specializations[i]->expr.did = d->decl.did;
+
+ /* we need to sub in default types in the specialization, so call
+ * typesub on the specialized function */
+ typesub(st, d);
popstab();
}
}