UVM sequence item randomization

Is foreach not allowed in the context of active randomization? I see this can be done in std::randomize call. I am getting an error system verilog foreach is not expected to be used in this context.

assert(item.randomize() with {
          (!(foreach(item.addr[i]) { item.addr[i] inside {addr_q}};)); });

Please show us the actual error and a minimal, complete reproducible example