forked from M-Labs/artiq
1
0
Fork 0

Fix inference for globals.

This commit is contained in:
whitequark 2015-07-18 08:13:49 +03:00
parent 0d66bdfbf8
commit 21eafefd28
3 changed files with 7 additions and 6 deletions

View File

@ -18,7 +18,7 @@ class scoped(object):
:ivar typing_env: (dict with string keys and :class:`.types.Type` values) :ivar typing_env: (dict with string keys and :class:`.types.Type` values)
map of variable names to variable types map of variable names to variable types
:ivar globals_in_scope: (set of string keys) :ivar globals_in_scope: (set of string keys)
list of variables resolved as globals set of variables resolved as globals
""" """
# Typed versions of untyped nodes # Typed versions of untyped nodes

View File

@ -151,8 +151,8 @@ class LocalExtractor(algorithm.Visitor):
continue continue
self.global_.add(name) self.global_.add(name)
self._assignable(name) if name in self.env_stack[1]:
self.env_stack[1][name] = self.typing_env[name] self.typing_env[name] = self.env_stack[1][name]
def visit_Nonlocal(self, node): def visit_Nonlocal(self, node):
for name, loc in zip(node.names, node.name_locs): for name, loc in zip(node.names, node.name_locs):

View File

@ -1,8 +1,9 @@
# RUN: %python -m artiq.compiler.testbench.inferencer %s >%t # RUN: %python -m artiq.compiler.testbench.inferencer %s >%t
# RUN: OutputCheck %s --file-to-check=%t # RUN: OutputCheck %s --file-to-check=%t
# CHECK-L: []:list(elt=int(width='a))
x = []
def f(): def f():
global x global x
x = 1 x[0] = 1
# CHECK-L: [x:int(width='a)]
[x]