commit ad70a2b

shrub  ·  2026-11-17 15:13:34 +0000 UTC
parent 24c086a
fix
2 files changed,  +3, -7
M kav.h
M kav.h
+1, -0
1@@ -56,6 +56,7 @@ noreturn void erroratv(const struct location *, const char *const *, usize);
2 char *tokdup(struct token);
3 int tokeqb(struct token, const char *, usize);
4 #define tokis(t, lit) tokeqb((t), (lit), sizeof(lit) - 1)
5+#define tokeq(a, b) tokeqb((a), (b).str, (b).length)
6 
7 /* if we're going to have variatic arity we're going to do it properly. */
8 #define errorat(loc, ...) erroratv(loc, STRS(__VA_ARGS__))
+2, -7
 1@@ -7,7 +7,6 @@
 2 #include "builtins.h"
 3 #undef BUILTIN
 4 
 5-
 6 enum space {
 7 	STYPE,
 8 	SVALUE,
 9@@ -22,11 +21,6 @@ struct scope {
10 
11 static void walksparams(struct scope *s, struct param *p);
12 
13-static int
14-tokeq(struct token a, struct token b) {
15-	return (a.length == b.length && memcmp(a.str, b.str, a.length) == 0);
16-}
17-
18 static struct binding *
19 lookin(struct scope *s, enum space sp, struct token name) {
20 	struct binding *b;
21@@ -299,6 +293,7 @@ walktypedecl(struct scope *up, struct decl *d) {
22 		walk(&inner, STYPE, c->ret);
23 	}
24 }
25+
26 static struct binding *
27 builtin(struct scope *s, enum space sp, enum bindkind kind, const char *str) {
28 	struct token t = {0};
29@@ -343,7 +338,7 @@ collect(struct scope *s, struct decl *d) {
30 		case DUSE:
31 			if(d->alias.length == 0)
32 				break;
33-			for(e = s->mod->decls; e == d; e = e->next)
34+			for(e = s->mod->decls; e != d; e = e->next)
35 				if(e->kind == DUSE && tokeq(e->alias, d->alias))
36 					errorat(&d->alias.loc, "module alias '", tokdup(d->alias), "' is already in use");
37 		}