From 6d8cfa9b42cf12eff46793758345783df28beaad Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 22 Jun 2024 22:57:20 +0200 Subject: If a key is unset, default it to AST_EMPTY --- src/analyzer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3