Commit 5966fd95 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Bug fix for #218, where expressions were not handled correctly in qubit array allocation

parent 2d345f9d
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -33,9 +33,11 @@ antlrcpp::Any qasm3_visitor::visitQuantumDeclaration(
    auto var_name = idx_identifier->Identifier()->getText();
    auto exp_list = idx_identifier->expressionList();
    if (exp_list) {
      try {
        size = std::stoi(exp_list->expression(0)->getText());
      } catch (...) {
      auto opt_size = symbol_table.try_evaluate_constant_integer_expression(
          exp_list->expression(0)->getText());
      if (opt_size.has_value()) {
        size = opt_size.value();
      } else {
        // check if this is a constant expression
        qasm3_expression_generator exp_generator(builder, symbol_table,
                                                 file_name);