ref: 3129d5a76e63713a29a66de9a26edd0093dd92a3
parent: e4739ae1457f3dccadbc53afbd160bc6f188cd4d
author: Ori Bernstein <[email protected]>
date: Fri Jun 22 17:57:33 EDT 2012
Fix a couple of crashes.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -877,11 +877,11 @@
void specialize(Node *f)
{
- Node *d, *name;
+ Node *name;
size_t i;
for (i = 0; i < nspecializations; i++) {
- d = specializedcl(genericdecls[i], specializations[i]->expr.type, &name);
+ specializedcl(genericdecls[i], specializations[i]->expr.type, &name);
specializations[i]->expr.args[0] = name;
}
}
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -173,9 +173,9 @@
p = buf;
end = buf + sz;
- p += snprintf(buf, end - p, "$%d", t->tid);
+ p += snprintf(p, end - p, "$%d", t->tid);
for (i = 0; i < t->nsub; i++)
- p += tidappend(buf, end - p, t->sub[i]);
+ p += tidappend(p, end - p, t->sub[i]);
return end - p;
}
@@ -208,8 +208,8 @@
fillsubst(tsmap, to, n->decl.type);
d = specializenode(n, tsmap);
d->decl.name = *name;
- dump(d, stdout);
+ d->decl.isgeneric = 0; /* we've specialized it */
putdcl(file->file.globls, d);
- lappend(&n->file.stmts, &n->file.nstmts, d);
+ lappend(&file->file.stmts, &file->file.nstmts, d);
return d;
}