chapel
chapel copied to clipboard
[Bug]: `const ref` attached to vararg formal arguments allows their modification
Summary of Problem
Description: This is the remaining issue tracked by #25858 which I wasn't able to solve yet.
The individual arguments passed to a const ref
varargs should behave the same as though they were passed to a const ref
tuple or individually - they should trigger an error about modifying a const
if the body of the function tries to modify them. However, today a program that does so compiles without issue and allows modification to occur.
This was easily solved for const
and const in
, but const ref
for some reason is proving more elusive.
Is this issue currently blocking your progress? No, just tracking it
Steps to Reproduce
Source Code:
proc myPrintln(const ref args...)
{
writeln("args.type = ", args.type:string);
writeln("args (before) = ", args);
args[0] *= 10; // should not be allowed
writeln("args (after) = ", args);
}
myPrintln(1, 2.3, "four");
Compile command:
chpl foo.chpl
Execution command: N/A - should fail at compilation, but does not
Associated Future Test(s):
test/functions/varargs/constRefVarargs.chpl
#25902
Configuration Information
- Output of
chpl --version
: 2.2.0 pre-release - Output of
$CHPL_HOME/util/printchplenv --anonymize
: any - Back-end compiler and version, e.g.
gcc --version
orclang --version
: any - (For Cray systems only) Output of
module list
: N/A