mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 11:18:27 +08:00
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)
|
||||
map of variable names to variable types
|
||||
: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
|
||||
|
@ -151,8 +151,8 @@ class LocalExtractor(algorithm.Visitor):
|
||||
continue
|
||||
|
||||
self.global_.add(name)
|
||||
self._assignable(name)
|
||||
self.env_stack[1][name] = self.typing_env[name]
|
||||
if name in self.env_stack[1]:
|
||||
self.typing_env[name] = self.env_stack[1][name]
|
||||
|
||||
def visit_Nonlocal(self, node):
|
||||
for name, loc in zip(node.names, node.name_locs):
|
||||
|
@ -1,8 +1,9 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.inferencer %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: []:list(elt=int(width='a))
|
||||
x = []
|
||||
|
||||
def f():
|
||||
global x
|
||||
x = 1
|
||||
# CHECK-L: [x:int(width='a)]
|
||||
[x]
|
||||
x[0] = 1
|
||||
|
Loading…
Reference in New Issue
Block a user