summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse/stab.c5
-rw-r--r--parse/use.c12
2 files changed, 12 insertions, 5 deletions
diff --git a/parse/stab.c b/parse/stab.c
index 7c031f9..c24b4a4 100644
--- a/parse/stab.c
+++ b/parse/stab.c
@@ -523,9 +523,12 @@ puttrait(Stab *st, Node *n, Trait *c)
st = findstab(st, n);
t = gettrait(st, n);
- if (t && !mergetrait(t, c))
+ if (t) {
+ if (mergetrait(t, c))
+ return;
fatal(n, "trait %s already defined on %s:%d",
namestr(n), fname(t->loc), lnum(t->loc));
+ }
ty = gettype(st, n);
if (ty)
fatal(n, "trait %s defined as a type on %s:%d",
diff --git a/parse/use.c b/parse/use.c
index d446503..b25e914 100644
--- a/parse/use.c
+++ b/parse/use.c
@@ -1168,6 +1168,7 @@ writeuse(FILE *f, Node *file)
{
Stab *st;
void **k;
+ Trait *tr;
Node *s, *u;
size_t i, n;
@@ -1211,14 +1212,17 @@ writeuse(FILE *f, Node *file)
}
}
- for (i = 0; i < ntraittab; i++) {
- if (i < Ntraits || i != traittab[i]->uid)
+ k = htkeys(st->tr, &n);
+ for (i = 0; i < n; i++) {
+ tr = gettrait(st, k[i]);
+ if (tr->uid < Ntraits)
continue;
- if (traittab[i]->vis == Visexport || traittab[i]->vis == Vishidden) {
+ if (tr->vis == Visexport || tr->vis == Vishidden) {
wrbyte(f, 'R');
- traitpickle(f, traittab[i]);
+ traitpickle(f, tr);
}
}
+ free(k);
k = htkeys(st->impl, &n);
for (i = 0; i < n; i++) {