0
Fixed

[W508] False positive with method adding a new item to a list

Uwe Schuster 10 years ago updated by Roman 10 years ago 3
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.