From a4cc3e44e0fcf15159c68f7af45e8decd0c30ba4 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Mon, 24 Jan 2022 21:24:19 +0000 Subject: Make sure variables are as local as they need to be --- symbol.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'symbol.c') diff --git a/symbol.c b/symbol.c index 2edb572..ed6006d 100644 --- a/symbol.c +++ b/symbol.c @@ -38,6 +38,10 @@ getsym(Rune *name, int fresh) done = 1; }while(!done && !fresh); + /* make sure to allocate in the most local scope if the symbol is not found */ + if(currentdfn) + tab = currentdfn->symtab; + tab->nsyms++; tab->syms = realloc(tab->syms, sizeof(Symbol *) * tab->nsyms); tab->syms[tab->nsyms-1] = emalloc(sizeof(Symbol)); -- cgit v1.2.3