Version: Mathematica 11.3.0.0 Platform: Windows 64
If I am not mistaken, there is a bug in the For loop implementation. If I am wrong, please correct me.
It looks like the loop variable is not localized properly. Consider:
test[n_] := Module[{}, If[n > 2, Return[]]; Do[Print[{i,n}];test[n+1],{i,2}] ]; test[1]
This works o.k., the output is: {1,1 } {1,2} {2,2} {2,1} {1,2} {2,2}
Now consider:
test[n_] := Module[{}, If[n > 2, Return[]]; For[i = 1, i <= 2, i++, Print[{i, n}]; test[n + 1]] ]; test[1]
Now the output is wrong: {1,1} {1,2} {2,2}
However, if one localizes the loop variable i in the module, it again works o.k.:
test[n_] := Module[{i}, If[n > 2, Return[]]; For[i = 1, i <= 2, i++, Print[{i, n}]; test[n + 1]] ]; test[1]
Now the output is again : {1,1 } {1,2} {2,2} {2,1} {1,2} {2,2}