Commit a5f62c4e authored by Nguyen, Thien's avatar Nguyen, Thien
Browse files

Fixed a bug in ScopedSymbolTable::invalidate_qubit_extracts



Must check the optional return before trying to deref.

This shows up in one of the demos whereby the QASM3 source only contains a kernel **definition** and the size of qreg argument is unknown.
Signed-off-by: Nguyen, Thien's avatarThien Nguyen <nguyentm@ornl.gov>
parent 75782600
......@@ -224,6 +224,9 @@ std::optional<size_t> ScopedSymbolTable::get_qreg_size(const std::string &qreg_n
void ScopedSymbolTable::invalidate_qubit_extracts(
const std::string &qreg_name, const std::vector<int> &indices) {
if (!get_qreg_size(qreg_name).has_value()) {
return;
}
if (indices.empty()) {
const auto reg_size = get_qreg_size(qreg_name).value();
for (size_t i = 0; i < reg_size; ++i) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment