# Buggy code
def _define(self):
    """
    gate sdg a { u1(-pi/2) a; }
    """
    definition = []
    q = QuantumRegister(1, "q")
    rule = [(U1Gate(-pi / 2), q[0], [])]
    for inst in rule:
        definition.append(inst)
    self.definition = definition


# Traceback (DAGCircuitError)
---------------------------------------------------------------------------
DAGCircuitError                           Traceback (most recent call last)
<ipython-input-6-9eea536c17ec> in <module>()
10
11 result = execute(qc, backend, basis_gates=['u1', 'u2', 'u3']).result()
---> 12 qobj = compile(qc, backend, basis_gates=['u1', 'u2', 'u3'])

~/git/qiskit/terra/qiskit/tools/compiler.py in compile(circuits, backend, config, basis_gates, coupling_map, initial_layout, shots, max_credits, seed, qobj_id, seed_mapper, pass_manager, memory)
65
66     new_circuits = transpiler.transpile(circuits, backend, basis_gates, coupling_map,
---> 67                                         initial_layout, seed_mapper, pass_manager)
68
69     qobj = assemble_circuits(new_circuits, qobj_header=None, run_config=run_config,

~/git/qiskit/terra/qiskit/transpiler/transpiler.py in transpile(circuits, backend, basis_gates, coupling_map, initial_layout, seed_mapper, pass_manager)
88                                          'initial_layout': initial_layout,
89                                          'seed_mapper': seed_mapper,
---> 90                                          'pass_manager': pass_manager})
91     if return_form_is_single:
92         return circuits[0]

~/git/qiskit/terra/qiskit/tools/parallel.py in parallel_map(task, values, task_args, task_kwargs, num_processes)
91     """
92     if len(values) == 1:
---> 93         return [task(values[0], *task_args, **task_kwargs)]
94
95     Publisher().publish("terra.parallel.start", len(values))

~/git/qiskit/terra/qiskit/transpiler/transpiler.py in _transpilation(***failed resolving arguments***)
147                               initial_layout=initial_layout,
148                               seed_mapper=seed_mapper,
--> 149                               pass_manager=pass_manager)
150
151     out_circuit = dag_to_circuit(final_dag)

~/git/qiskit/terra/qiskit/transpiler/transpiler.py in transpile_dag(dag, basis_gates, coupling_map, initial_layout, seed_mapper, pass_manager)
221         name = dag.name
222
--> 223         dag = Unroller(basis_gates).run(dag)
224         dag = BarrierBeforeFinalMeasurements().run(dag)
225

~/git/qiskit/terra/qiskit/transpiler/passes/unroller.py in run(self, dag)
59             # TODO: need anonymous rules to address wires by index
60             decomposition = DAGCircuit()
---> 61             decomposition.add_qreg(rule[0][1][0][0])
62             for inst in rule:
63                 decomposition.apply_operation_back(*inst)

~/git/qiskit/terra/qiskit/dagcircuit/dagcircuit.py in add_qreg(self, qreg)
163         """Add all wires in a quantum register."""
164         if not isinstance(qreg, QuantumRegister):
--> 165             raise DAGCircuitError("not a QuantumRegister instance.")
166         if qreg.name in self.qregs:
167             raise DAGCircuitError("duplicate register %s" % qreg.name)

DAGCircuitError: 'not a QuantumRegister instance.'

# Fixed code
def _define(self):
    """
    gate sdg a { u1(-pi/2) a; }
    """
    definition = []
    q = QuantumRegister(1, "q")
    rule = [(U1Gate(-pi / 2), [q[0]], [])]
    for inst in rule:
        definition.append(inst)
    self.definition = definition