-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
MutableTuple allows creation of tuple of size greater than 128 by nesting tuples (e.g. a Tuple`2 which contains a Tuple`128 and a Tuple`8 if we had a size of 136). In fact, the accessor methods (e.g. MutableTuple.GetAccessPath) expect nested tuples to be laid out exactly this way. However the MutableTuple.GetSize method traverses the whole tuple and also counts the number of elements of any generic argument of type MutableTuple.
Because the size is calculated incorrectly MutableTuple.GetAccessPath can have unexpected behavior. For example, the following should throw ArgumentException but ends up throwing InvalidOperationException:
int size = 8;
Type[] args = new Type[size];
for (int i = 0; i < size; i++) {
if (i == 5) {
args[i] = MutableTuple.MakeTupleType(typeof(int), typeof(int));
} else {
args[i] = typeof(int);
}
}
var tupleType = MutableTuple.MakeTupleType(args);
MutableTuple.GetAccessPath(tupleType, 8).ToArray(); // this should throw ArgumentException since the index 8 >= sizeThis also causes the failure in IronLanguages/ironpython3#926
Metadata
Metadata
Assignees
Labels
No labels