I forgot about the reasons for lines 10 and 12. Thanks. Now it makes sense.
Sorry about my example. It is incomplete. The real code that was failing was more like the following:
if ( BLAH > 2 ) begin
assign y = dut.foo2.x;
end
And “dut” code was generated using some kind of VPP tool so that the number of foo instances were dependent on the same source variable as the BLAH parameter. Besides the `ifdef approach, I could use VPP to also generate the code with the DUT XMR’s but I’m not a big fan of VPP.
I wonder if/how it would work if “dut” uses generate to instantiate the foo instances instead of using VPP.