aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-06-22 22:57:20 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-06-22 22:57:20 +0200
commit6d8cfa9b42cf12eff46793758345783df28beaad (patch)
treefdd1f774eb443afad4c587b4035a3987f6aa9665
parentae7b78426908e77f19cc34d5e096103141d08969 (diff)
If a key is unset, default it to AST_EMPTY
-rw-r--r--src/analyzer.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/analyzer.c b/src/analyzer.c
index 6b7888e..f665d4c 100644
--- a/src/analyzer.c
+++ b/src/analyzer.c
@@ -145,7 +145,7 @@ find_unordered_syms(scopes_t *scps, ast_t ast, aux_t aux, lexemes_t toks,
if (isstatic || isconst) {
strview_t sv = toks.strs[ast.lexemes[i]];
idx_t *p = symtab_insert(&scp->map, sv, a);
- if (*p != 0) {
+ if (*p != AST_EMPTY) {
err("analyzer: Symbol ā€˜%.*sā€™ declared multiple times",
SV_PRI_ARGS(sv));
}
@@ -186,7 +186,7 @@ analyzedecl(struct azctx ctx, scope_t *scps, type_t *types, ast_t ast,
strview_t sv = toks.strs[ast.lexemes[i]];
if (ctx.si > 0 && ast.kinds[i] == ASTDECL) {
idx_t *ip = symtab_insert(&scps[ctx.si].map, sv, ctx.a);
- if (*ip == 0)
+ if (*ip == AST_EMPTY)
*ip = i;
else {
err("analyzer: Variable ā€˜%.*sā€™ declared multiple times",
@@ -529,5 +529,6 @@ symtab_insert(symtab **m, strview_t k, arena_t *a)
return NULL;
*m = arena_new(a, symtab, 1);
(*m)->key = k;
+ (*m)->val = AST_EMPTY;
return &(*m)->val;
}