mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 21:40:08 +00:00
enforce scope definitions in for loop declarations
This commit is contained in:
1 parent
2e68a0db5d
commit
bbab6e39ff
1 file changed
+3
@@ -128,6 +128,9 @@ public class Parser {
|
|||||||
ParserUtil.checkType(tokens.consume(), Token.Type.STRING_VARIABLE, Token.Type.BOOLEAN_VARIABLE, Token.Type.NUMBER_VARIABLE);
|
ParserUtil.checkType(tokens.consume(), Token.Type.STRING_VARIABLE, Token.Type.BOOLEAN_VARIABLE, Token.Type.NUMBER_VARIABLE);
|
||||||
Token name = tokens.get();
|
Token name = tokens.get();
|
||||||
|
|
||||||
|
if(functions.containsKey(name.getContent()) || variableMap.containsKey(name.getContent()) || builtinFunctions.contains(name.getContent()))
|
||||||
|
throw new ParseException(name.getContent() + " is already defined in this scope: " + name.getPosition());
|
||||||
|
|
||||||
initializer = parseAssignment(forVar, tokens, variableMap);
|
initializer = parseAssignment(forVar, tokens, variableMap);
|
||||||
variableMap.put(name.getContent(), forVar);
|
variableMap.put(name.getContent(), forVar);
|
||||||
} else initializer = parseExpression(tokens, true, variableMap);
|
} else initializer = parseExpression(tokens, true, variableMap);
|
||||||
|
|||||||
Reference in new issue
Block a user