
0
Fixed
[W508] False positive with method adding a new item to a list
Methods that add for example items to a list may lead to a false positive W508 warning
Sample code:
type
TItem = class(TObject)
Prop: Boolean;
end;
TItemList = class(TObject)
public
function Add: TItem;
end;
function TItemList.Add: TItem;
begin
{
FItems.Add(TItem.Create);
Result := FItems.Last;
}
end;
procedure Test;
var
List: TItemList;
begin
List.Add.Prop := False;
List.Add.Prop := False;//<- W508 Variable is assigned twice successively
end;
Also when Add has a parameter (e.g. AName) and both Add calls have the same value then W508 occurs.
Sample code:
type
TItem = class(TObject)
Prop: Boolean;
end;
TItemList = class(TObject)
public
function Add: TItem;
end;
function TItemList.Add: TItem;
begin
{
FItems.Add(TItem.Create);
Result := FItems.Last;
}
end;
procedure Test;
var
List: TItemList;
begin
List.Add.Prop := False;
List.Add.Prop := False;//<- W508 Variable is assigned twice successively
end;
Also when Add has a parameter (e.g. AName) and both Add calls have the same value then W508 occurs.

0
Planned
Roman 10 years ago

0
Started
Roman 10 years ago

0
Fixed
Roman 10 years ago
Customer support service by UserEcho