From e299801c0f68cc2060b2b0b596fc34c5e3d07ddd Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 21 Jul 2015 13:16:18 +0300 Subject: [PATCH] LocalAccessValidator: fix validation of closures with no outer variables. --- artiq/compiler/validators/local_access.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/artiq/compiler/validators/local_access.py b/artiq/compiler/validators/local_access.py index ee43b30a7..c86f3e46b 100644 --- a/artiq/compiler/validators/local_access.py +++ b/artiq/compiler/validators/local_access.py @@ -99,12 +99,14 @@ class LocalAccessValidator: if isinstance(insn, ir.Closure): env = insn.environment() - for var_name in block_state[env]: - if not block_state[env][var_name]: - # A closure would capture this variable while it is not always - # initialized. Note that this check is transitive. - self._uninitialized_access(insn, var_name, - pred_at_fault(env, var_name)) + # Make sure this environment has any interesting variables. + if env in block_state: + for var_name in block_state[env]: + if not block_state[env][var_name]: + # A closure would capture this variable while it is not always + # initialized. Note that this check is transitive. + self._uninitialized_access(insn, var_name, + pred_at_fault(env, var_name)) # Save the state. state[block] = block_state