forked from M-Labs/artiq
Fix inference for globals.
This commit is contained in:
parent
0d66bdfbf8
commit
21eafefd28
@ -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
|
||||||
|
@ -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):
|
||||||
|
@ -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]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user