varargs should disallow out and in arguments. There is no way the calee can express its part of the contract.
We currently allow both and out was allowed in old compiler versions too. We should disallow both.
Arguably it would be a breaking change for out, but it is very unlikely it would affect real code.
Example:
class Program
{
static void Main(string[] args)
{
int unassigned;
int doNotChange = 42;
Test(__arglist(out unassigned, in doNotChange)); // <-- out? in? really?
System.Console.WriteLine(unassigned);
System.Console.WriteLine(doNotChange);
}
static void Test(__arglist)
{
var args = new ArgIterator(__arglist);
// leave unassigned unassigned
ref var unassigned = ref __refvalue(args.GetNextArg(), int);
// assign junk to doNotChange
ref var doNotChange = ref __refvalue(args.GetNextArg(), int);
doNotChange = unassigned;
}
}
varargs should disallow
outandinarguments. There is no way the calee can express its part of the contract.We currently allow both and
outwas allowed in old compiler versions too. We should disallow both.Arguably it would be a breaking change for
out, but it is very unlikely it would affect real code.Example: