summaryrefslogtreecommitdiff
path: root/parse/specialize.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-07-18 23:53:25 -0700
committerOri Bernstein <ori@eigenstate.org>2015-07-18 23:53:25 -0700
commit4e656a4f039b9230c820f12d3b1e4a5c8e55cf47 (patch)
treec3b213a2750d7b027bb4510b5824fcf6374ab3f6 /parse/specialize.c
parent3942d40cb5532fe51ac97e5a15610d20a0691fa3 (diff)
downloadmc-4e656a4f039b9230c820f12d3b1e4a5c8e55cf47.tar.gz
Don't create duplicate types if we have no parameters.
Diffstat (limited to 'parse/specialize.c')
-rw-r--r--parse/specialize.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/parse/specialize.c b/parse/specialize.c
index 5755406..77230c0 100644
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -40,6 +40,8 @@ Type *tyspecialize(Type *t, Htab *tsmap, Htab *delayed)
t = tysearch(t);
if (hthas(tsmap, t))
return htget(tsmap, t);
+ arg = NULL;
+ narg = 0;
switch (t->type) {
case Typaram:
ret = mktyvar(t->loc);
@@ -54,8 +56,8 @@ Type *tyspecialize(Type *t, Htab *tsmap, Htab *delayed)
lappend(&ret->arg, &ret->narg, tyspecialize(t->gparam[i], tsmap, delayed));
break;
case Tyname:
- arg = NULL;
- narg = 0;
+ if (!hasparams(t))
+ return t;
for (i = 0; i < t->narg; i++)
lappend(&arg, &narg, tyspecialize(t->arg[i], tsmap, delayed));
ret = mktyname(t->loc, t->name, tyspecialize(t->sub[0], tsmap, delayed));