Fix leaking scope of function to outer scope

This commit is contained in:
Bartłomiej Pluta
2019-07-16 10:18:00 +02:00
parent 6e9e252b86
commit ea28ab6235
5 changed files with 18 additions and 115 deletions

View File

@@ -13,7 +13,7 @@ class LoopEvaluator(Evaluator):
parameters = [ identifier.value for identifier in node.parameters ] if type(node.parameters) != NoneNode() else []
try:
environment.scopes.append({})
environment.appendScope()
output = {
Type.INTEGER: cls.numberEvaluator,
@@ -22,7 +22,7 @@ class LoopEvaluator(Evaluator):
Type.MAP: cls.mapEvaluator
}[iterator.type](node, environment, iterator, parameters, node.filter)
environment.scopes.pop(-1)
environment.popScope()
except KeyError:
raise RuntimeException(f"The {iterator.type.name.lower()} type cannot stand as an iterator for loop statement", node.left.pos)