16743, “bradcray”, “Module-scope variables are not shadowed consistently”, “2020-11-19T01:35:02Z”
As @vasslitvinov pointed out in this comment on issue #16716, we currently don’t introduce shadow variables for module-scope variables for coforall
loops as we do for forall
loops. Here’s the test he used to demonstrate this:
module Lib {
var globalLib = 10;
proc updateLib() { globalLib += 1; }
}
module Main {
use Lib;
var s$: sync int;
var globalMain = 20;
proc updateMain() { globalMain += 1; }
proc main {
coforall 1..2 {
s$ = 1; // grab the lock
writeln("globaLib = ", globalLib);
writeln("globalMain = ", globalMain);
updateLib();
updateMain();
s$;
}
}
}
where the output is:
globaLib = 10
globalMain = 20
globaLib = 11 // should be 10
globalMain = 20
However, if the coforall
is changed to forall
, we get the expected result.