I have the following code that doesn't compile, and I can't find an explanation as to why.
TIndexArray<TType> = array of TType;
TIndexList<TArrayType; TType: TIndexArray<TArrayType>> = class
end;
It says the
Type 'TIndexArray' is not a valid constraint.
But if TIndexArray is a class and not an array type it works.
CodePudding user response:
Array types are not supported as constraints. This is documented behavior:
https://docwiki.embarcadero.com/RADStudio/en/Constraints_in_Generics
Constraint items include:
Zero, one, or multiple interface types
Zero or one class type
The reserved word "constructor", "class", or "record"
No mention of array types.