Branch: refs/heads/master
Revision: a457fbc
Author: dlongnecke-cray
Log Message:
Add const checking for elements of tuple formals (#16041)
Add const checking for elements of tuple formals (#16041)
This PR adjusts the compiler to emit errors when a const element of
a tuple formal is modified. Prior to this PR the compiler would
compile programs such as the following without incident:
record r { var x: int = 0; }
proc modifyDefaultIntentFormal(tup) {
tup[1] = new r(128);
}
proc test() {
const a = (0, new r(0));
modifyDefaultIntentFormal(a);
writeln(a);
}
test();
The call to modifyDefaultIntentFormal
incorrectly modifies the
second element of the tuple formal tup
. Because tup
has the
default argument intent, its second element should be passed by
const ref
(because it is a record). Any modification of tup[1]
within the body of modifyDefaultIntentFormal
should emit an error.