diff --git a/src/cparse.c b/src/cparse.c index afe2c7f..f51ad27 100644 --- a/src/cparse.c +++ b/src/cparse.c @@ -1018,7 +1018,9 @@ static void forLoop(CParseState *pstate) { consume(pstate, TOKEN_DO, "Expected 'do'"); + beginScope(pstate); // fixes stack issues block(pstate); // parses until 'end' + endScope(pstate); writeJmpBack(pstate, loopStart); diff --git a/test.cosmo b/test.cosmo index eb73b10..3029113 100644 --- a/test.cosmo +++ b/test.cosmo @@ -4,7 +4,7 @@ class test end function print(self, i) - local str = self.hello + var str = self.hello for (var x = i; x > 0; x=x-1) do str = str .. "!"