correct scope wackiness in for loops

This commit is contained in:
dfsek
2020-12-31 02:06:53 -07:00
parent ad5823055d
commit 122fbd841c
2 changed files with 6 additions and 1 deletions

View File

@@ -187,7 +187,8 @@ public class Parser {
}
}
private ForKeyword parseForLoop(TokenHolder tokens, Map<String, Variable<?>> variableMap, Position start) throws ParseException {
private ForKeyword parseForLoop(TokenHolder tokens, Map<String, Variable<?>> old, Position start) throws ParseException {
Map<String, Variable<?>> variableMap = new HashMap<>(old);
Token f = tokens.get();
ParserUtil.checkType(f, Token.Type.NUMBER_VARIABLE, Token.Type.STRING_VARIABLE, Token.Type.BOOLEAN_VARIABLE, Token.Type.IDENTIFIER);
Item<?> initializer;

View File

@@ -22,6 +22,10 @@ for(num i = 0; i < 5; i = i + 1) {
test("i = " + i, iterator);
}
for(num i = 0; i < 5; i = i + 1) {
test("i = " + i, iterator);
}
for(num j = 0; j < 5; j = j + 1) test("single statement j = " + j, iterator);
if(4 + 2 == 2 + 4) {