1

Topic: Delphi XE4, an easy bug in

At once  the dimensionless listing for those who such does not fear.
[spoiler]

program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System. SysUtils;
rtti;
type
//TSomeType = (stA, stB, stC);
TSomeType = (stA, stB, stC, stD, stE, stF, stG, stH, stI, stJ, stK, stL, stM;
stN, stO, stP, stQ, stR, stT, stU, stV, stW, stX, stY, stZ, st0, st1, st2;
st3, st4, st5, st6, st7, st8, st9);
TSomeTypeSet = set of TSomeType;
type
SomeAttribute = class (TCustomAttribute)
private
FElements: TSomeTypeSet;
public
constructor Create ({const} AttrElements: TSomeTypeSet);
property Elements: TSomeTypeSet read FElements;
end;
[SomeAttribute ([stA, stC])]
TClassWithAttribute = class
end;
function GetChildrenFor (aClass: TClass): TSomeTypeSet;
var
rttiContext: TRttiContext;
rttiType: TRttiType;
attribute: TCustomAttribute;
begin
rttiContext: = TRttiContext. Create;
try
rttiType: = rttiContext. GetType (aClass);
for attribute in rttiType. GetAttributes do//<- falls here
if attribute is SomeAttribute then
Exit (SomeAttribute (attribute).Elements);
Result: = [];
finally
rttiContext. Free;
end;//try to recover and return the DisplayLabel
end;
{SomeAttribute}
constructor SomeAttribute. Create ({const} AttrElements: TSomeTypeSet);
begin
FElements: = AttrElements;
end;
var
Elements: TSomeTypeSet;
El: TSomeType;
begin
try
Elements: = GetChildrenFor (TClassWithAttribute);
for El in Elements do
Writeln (format (' Element: %d ', [integer (El)]));
readln;
except
on E: Exception do
begin
Writeln (E.ClassName, ': ', E.Message);
readln;
end;
end;
end.

[/spoiler]
Sense of a bug that in attribute the different data type depending on an amount  in enumerated type is compiled.
If in type TSomeType to leave some elements - the resulted program works, differently falls, because instead of a set in  the array from 2 elements is transferred and at attribute creation  the designer falls with error Invalid class typecast.
I do not know, whether is what to consider here and whether the bug in newer versions is solved, but I will leave it here for the information.

2

Re: Delphi XE4, an easy bug in

Dimonka;
If I am not mistaken, the bug is connected to incorrect determination of the size of set. , like, in a berlin only.

3

Re: Delphi XE4, an easy bug in

Tried to transfer the member list as array of const, an error:
[quote =] E2150 Bad argument type in variable type array constructor

Delfi not so is similar loves sets with an amount of elements> 32