diff --git a/pytket/pytket/circuit/decompose_classical.py b/pytket/pytket/circuit/decompose_classical.py index 4da597ce0a..058a9f2b3b 100644 --- a/pytket/pytket/circuit/decompose_classical.py +++ b/pytket/pytket/circuit/decompose_classical.py @@ -508,10 +508,7 @@ def _decompose_expressions(circ: Circuit) -> tuple[Circuit, bool]: newcirc.add_barrier(args) else: for arg in args: - if ( - isinstance(arg, Bit) - and arg not in newcirc.bits - ): + if isinstance(arg, Bit) and arg not in newcirc.bits: newcirc.add_bit(arg) newcirc.add_gate(op, args, **kwargs) return newcirc, modified diff --git a/pytket/tests/classical_test.py b/pytket/tests/classical_test.py index c3b38c4672..81e3da2b01 100644 --- a/pytket/tests/classical_test.py +++ b/pytket/tests/classical_test.py @@ -585,6 +585,25 @@ def test_wasm_append_2() -> None: assert d.depth() == 3 +def test_wasm_append_3() -> None: + wfh = wasm.WasmFileHandler("testfile.wasm") + wfh2 = wasm.WasmFileHandler("testfile-without-init.wasm", check_file=False) + + c = Circuit(1) + a = c.add_c_register("a", 8) + c.add_wasm_to_reg("add_one", wfh, [a], [a]) + assert c.depth() == 1 + + d = Circuit() + for bit in c.bits: + d.add_bit(bit) + d.add_c_setbits([False], [bit]) + d.add_wasm_to_reg("no_return", wfh2, [a], []) + + with pytest.raises(ValueError): + d.append(c) + + def test_wasmfilehandler_without_init() -> None: with pytest.raises(ValueError): _ = wasm.WasmFileHandler("testfile-without-init.wasm")