diff --git a/new_resolve.cpp b/new_resolve.cpp index b11c7ed..c1d2059 100644 --- a/new_resolve.cpp +++ b/new_resolve.cpp @@ -44,28 +44,17 @@ sym_insert(Sym *sym){ Sym *is_sym = (Sym *)map_get(&pctx->syms, hash); if(is_sym){ parsing_error(sym->ast->pos, "Symbol with name: [%s] defined multiple times", sym->name.s.str); - return; } if(pctx->scope > 0){ - For(pctx->local_syms){ - if(it[0]->name.str == sym->name.str) parsing_error(sym->ast->pos, "Symbol with name: [%s] defined multiple times", sym->name.s.str); - return; - } pctx->local_syms.add(sym); } - else{ - map_insert(&pctx->syms, hash, sym); - } + + map_insert(&pctx->syms, hash, sym); } function Sym * sym_get(Intern_String name){ Sym *result = (Sym *)map_get(&pctx->syms, hash_string(name.s)); - if(!result){ - For(pctx->local_syms){ - if(it[0]->name.str == name.str) return it[0]; - } - } return result; } @@ -80,6 +69,11 @@ function void scope_close(S64 local_sym_count){ pctx->scope--; assert(pctx->scope >= 0); + for(S64 i = local_sym_count; i < pctx->local_syms.len; i++){ + Sym *it = pctx->local_syms.data[i]; + void *removed = map_remove(&pctx->syms, hash_string(it->name.s)); + assert(removed); + } pctx->local_syms.len = local_sym_count; }