softwareQinc / staq

Full-stack quantum processing toolkit
https://iopscience.iop.org/article/10.1088/2058-9565/ab9359/pdf
MIT License
155 stars 28 forks source link

Bug Report: staq hangs with these arguments #31

Closed DevelopDaily closed 4 years ago

DevelopDaily commented 4 years ago

Here is a test case (a slightly modified example code shipped with the staq).

The Verilog file toffoli_4.v

module top ( a, b, c, d, e );
  input a, b, c, d;
  output e;
  wire subprod1, subprod2;
  assign subprod1 = a & b;
  assign subprod2 = c & d;
  assign e = subprod1 & subprod2;
endmodule

The QASM file oracle_example.qasm

OPENQASM 2.0;
include "qelib1.inc";

oracle tof4 a,b,c,d,e { "toffoli_4.v" }

qreg q[5];

tof4 q[1],q[1],q[2],q[3],q[4];

Now run this. It will hang.

./staq -S -m -d tokyo -f resources oracle_example.qasm

Note that I deliberately introduced the typo q[1],q[1]. When that happens, would it be better for staqto throw an exception or something, instead of hanging?

meamy commented 4 years ago

Thanks for the bug report! I just pushed a fix. staq should now identify these errors in the semantic analysis phase and throw an exception.