ref: 1f07ea309194e550b726d4abc4295876854c3781
parent: 5e6ffbb015dc6f204b5da226dabac8b15d666216
author: Ori Bernstein <[email protected]>
date: Thu Aug 29 12:10:05 EDT 2013
Don't clobber the original type when specializing.
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -42,7 +42,7 @@
* against */
Type *tyspecialize(Type *t, Htab *tsmap)
{
- Type *ret;
+ Type *ret, *tmp;
size_t i;
if (hthas(tsmap, t))
@@ -77,9 +77,11 @@
ret = tydup(t);
htput(tsmap, t, ret);
for (i = 0; i < t->nmemb; i++) {
+ if (ret->udecls[i]->etype) {
+ tmp = tyspecialize(t->udecls[i]->etype, tsmap);
+ ret->udecls[i] = mkucon(t->line, t->udecls[i]->name, ret, tmp);
+ }
ret->udecls[i]->utype = ret;
- if (ret->udecls[i]->etype)
- ret->udecls[i]->etype = tyspecialize(t->udecls[i]->etype, tsmap);
}
break;
default: