Skip to content

Commit

Permalink
Fix missing defs operation = instruction.operation
Browse files Browse the repository at this point in the history
  • Loading branch information
jlapeyre committed May 30, 2024
1 parent ec68b28 commit db8fbad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qiskit/qasm3/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ def build_if_statement(self, instruction: CircuitInstruction) -> ast.BranchingSt

def build_switch_statement(self, instruction: CircuitInstruction) -> Iterable[ast.Statement]:
"""Build a :obj:`.SwitchCaseOp` into a :class:`.ast.SwitchStatement`."""
operation = instruction.operation
real_target = self.build_expression(expr.lift(operation.target))
global_scope = self.global_scope()
target = self._reserve_variable_name(
Expand Down Expand Up @@ -935,15 +936,15 @@ def case(values, case_block):
target,
(
case(values, block)
for values, block in instruction.operation.cases_specifier()
for values, block in operation.cases_specifier()
),
),
]

# Handle the stabilised syntax.
cases = []
default = None
for values, block in instruction.operation.cases_specifier():
for values, block in operation.cases_specifier():
self.push_scope(block, instruction.qubits, instruction.clbits)
case_body = ast.ProgramBlock(self.build_current_scope())
self.pop_scope()
Expand Down Expand Up @@ -972,6 +973,7 @@ def build_while_loop(self, instruction: CircuitInstruction) -> ast.WhileLoopStat

def build_for_loop(self, instruction: CircuitInstruction) -> ast.ForLoopStatement:
"""Build a :obj:`.ForLoopOp` into a :obj:`.ast.ForLoopStatement`."""
operation = instruction.operation
indexset, loop_parameter, loop_circuit = operation.params
self.push_scope(loop_circuit, instruction.qubits, instruction.clbits)
scope = self.current_scope()
Expand Down

0 comments on commit db8fbad

Please sign in to comment.