You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
intsize=8;Type[]args=newType[size];for(inti=0;i<size;i++){if(i==5){args[i]=MutableTuple.MakeTupleType(typeof(int),typeof(int));}else{args[i]=typeof(int);}}vartupleType=MutableTuple.MakeTupleType(args);MutableTuple.GetAccessPath(tupleType,8).ToArray();// this should throw ArgumentException since the index 8 >= size
MutableTuple
allows creation of tuple of size greater than 128 by nesting tuples (e.g. aTuple`2
which contains aTuple`128
and aTuple`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 theMutableTuple.GetSize
method traverses the whole tuple and also counts the number of elements of any generic argument of typeMutableTuple
.Because the size is calculated incorrectly
MutableTuple.GetAccessPath
can have unexpected behavior. For example, the following should throwArgumentException
but ends up throwingInvalidOperationException
:This also causes the failure in IronLanguages/ironpython3#926
The text was updated successfully, but these errors were encountered: