0

[W527] False positive

Lübbe Onken 10 years ago 0

And another one, better hidden this time :)


In my particular case FMyObject is an XML Node with a 'Text' child node, whose 'Text' property is returned. Simple example:

function TObject.GetText: String;
begin
  Result := FSubObject.Text.Text
end;

It's clear that in this case it is not the TObject.Text property which is accessed and may cause a recursion. It is the subsubobjects text property :)


I think W527 should just trigger on these two cases:

function TObject.GetText: String;
begin
  Result := Text
end;

function TObject.GetText: String;
begin
  Result := Self.Text
end;

Or did I miss something?


I have not tried what FixInsight reports, when FMyObject is an XML Node with a 'XYZ' child node, whose 'Text' property is returned or if FMyObject is an XML Node with a 'Text' child node, whose 'XYZ' property is returned.

function TObject.GetText: String;
begin
  Result := FSubObject.XYZ.Text
end;

function TObject.GetText: String;
begin
  Result := FSubObject.Text.XYZ
end;