# Expression of this type cannot be used to index the array

**URL:** <https://verificationacademy.com/forums/t/expression-of-this-type-cannot-be-used-to-index-the-array/35426>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, randomization-associative-array\
**Created:** [December 6, 2018, 9:17pm UTC](https://verificationacademy.com/forums/t/expression-of-this-type-cannot-be-used-to-index-the-array/35426 "2018-12-06T21:17:59Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [December 7, 2018, 5:17pm UTC](https://verificationacademy.com/forums/t/expression-of-this-type-cannot-be-used-to-index-the-array/35426/6 "2018-12-07T17:17:48Z")

</div>

_In reply to [desperadorocks](https://verificationacademy.com/forums/t/expression-of-this-type-cannot-be-used-to-index-the-array/35426/5):_

The syntax is not legal, though simulators other than the one you are using support it. You are only allowed one set of 's in a foreach loop. Normally you would do there following to skip of iterating one of the dimensions:

```verilog
foreach(agt_pts[,z])

```

But that doesn’t work when the z dimension is dynamically sized.

A few other non-standard code fragments

- **config** is a reserved keyword
- You cannot use an assignment pattern with named indexes to assign to a queue. Use array concatenation

```verilog
bit[7:0] agt_pts[string][$] = '{"alu0":{h11}, "cpu0":{h11,'h22}};

```

- You cannot initialize an implicitly static variable(aac\_inst) in its declaration. People mistakenly think it gets initialized as part of entering the procedural block it in.

---

_[View the full topic](https://verificationacademy.com/forums/t/expression-of-this-type-cannot-be-used-to-index-the-array/35426)._
