This error message comes from symbolic pre-evaluation performed by the outer NIntegrate
and has nothing related to Block
. The best is to combine the two NIntegrate
into one:
y = 1;
NIntegrate[E^(-x y z), {x, 0, 1}, {z, 0, 1}]
(* => 0.7965995998164899` *)
If the latter isn't possible, a workaround is to disable symbolic preprocessing by turning the inner integral into a black-box function (but it can considerably slow down integration):
Clear[f]
f[x_Real, y_] := NIntegrate[E^(-x y z), {z, 0, 1}]
Block[{y = 1}, NIntegrate[f[x, y], {x, 0, y}]]
(* => 0.7965995992970549` *)