For example, with the following code
for (i = 0; i < 2; i = i + 1) begin : Loop
defparam m.p = 1 + i;
the compiler issues the warning
defparam.v:11: warning: Scope of m.p not found.
and the defparam is not applied. Trying to work round this by
defparam Loop[i].m.p = 1 + i;
also fails with the error
defparam.v:11: error: Unable to bind parameter `i' in `m2'
The root cause of these problems is that defparams are treated as being in the scope of the enclosing module, rather than in the current lexical scope.
This can be worked round by overriding the parameter during module instation, like this
m1 #(.p(1 + i)) m();
Regression test attached.