File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ def rewrite_Statement(self, node: ir.Statement) -> RewriteResult:
137137
138138 def rewrite_IfElse (self , stmt : scf .IfElse ) -> RewriteResult :
139139
140- condition_type = self .measure_frame .entries [ stmt .cond ]
140+ condition_type = self .measure_frame .entries . get ( stmt .cond )
141141 # Check the condition is a singular MeasurementIdBool and that
142142 # it was generated by querying if the measurement is equivalent to the one state
143143 if not isinstance (condition_type , MeasureIdBool ):
@@ -162,9 +162,11 @@ def rewrite_IfElse(self, stmt: scf.IfElse) -> RewriteResult:
162162 return RewriteResult ()
163163
164164 # generate get record statement
165- measure_id_idx_stmt = py .Constant (
166- (condition_type .idx - 1 ) - self .measure_frame .num_measures_at_stmt [stmt ]
167- )
165+ num_measures = self .measure_frame .num_measures_at_stmt .get (stmt )
166+ if num_measures is None :
167+ return RewriteResult ()
168+
169+ measure_id_idx_stmt = py .Constant ((condition_type .idx - 1 ) - num_measures )
168170 get_record_stmt = GetRecord (id = measure_id_idx_stmt .result ) # noqa: F841
169171
170172 address_attr = stmts [0 ].qubits .hints .get ("address" )
You can’t perform that action at this time.
0 commit comments