commit e05c83a
shrub
·
2026-11-17 14:52:38 +0000 UTC
parent d4f2f64
error on duplicate module alias
1 files changed,
+6,
-3
+6,
-3
1@@ -244,8 +244,6 @@ walk(struct scope *s, enum space sp, struct expr *e) {
2 case EBORROW:
3 walk(s, sp, e->body);
4 break;
5- default:
6- break;
7 }
8 }
9
10@@ -320,6 +318,7 @@ builtins(struct scope *s) {
11 static void
12 collect(struct scope *s, struct decl *d) {
13 struct ctor *c;
14+ struct decl *e;
15
16 for(; d; d = d->next) {
17 switch(d->kind) {
18@@ -342,7 +341,11 @@ collect(struct scope *s, struct decl *d) {
19 }
20 break;
21 case DUSE:
22- break;
23+ if(d->alias.length == 0)
24+ break;
25+ for(e = s->mod->decls; e == d; e = e->next)
26+ if(e->kind == DUSE && tokeq(e->alias, d->alias))
27+ errorat(&d->alias.loc, "module alias '", tokdup(d->alias), "' is already in use");
28 }
29 /* every declared name knows its declaration */
30 if(d->binding)