Commit a161a389 authored by Tom Niget's avatar Tom Niget

Store scope for `else` block

parent 85bc07d7
...@@ -43,7 +43,8 @@ class FunctionVisitor(BlockVisitor): ...@@ -43,7 +43,8 @@ class FunctionVisitor(BlockVisitor):
if isinstance(node.orelse, ast.If): if isinstance(node.orelse, ast.If):
yield from self.visit(node.orelse) yield from self.visit(node.orelse)
else: else:
yield from self.emit_block(node.orelse.inner_scope, node.orelse) yield from self.emit_block(node.orelse_scope, node.orelse)
def visit_PlainBlock(self, node: PlainBlock) -> Iterable[str]: def visit_PlainBlock(self, node: PlainBlock) -> Iterable[str]:
yield from self.emit_block(node.inner_scope, node.body) yield from self.emit_block(node.inner_scope, node.body)
......
...@@ -145,7 +145,8 @@ class ScoperBlockVisitor(ScoperVisitor): ...@@ -145,7 +145,8 @@ class ScoperBlockVisitor(ScoperVisitor):
if node.orelse: if node.orelse:
else_scope = scope.child(ScopeKind.FUNCTION_INNER) else_scope = scope.child(ScopeKind.FUNCTION_INNER)
else_visitor = ScoperBlockVisitor(else_scope, self.root_decls) else_visitor = ScoperBlockVisitor(else_scope, self.root_decls)
else_visitor.visit_block(node.orelse.body) else_visitor.visit_block(node.orelse)
node.orelse_scope = else_scope
def visit_While(self, node: ast.While): def visit_While(self, node: ast.While):
scope = self.scope.child(ScopeKind.FUNCTION_INNER) scope = self.scope.child(ScopeKind.FUNCTION_INNER)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment