|
[D1,D2,D3,D4,D5,D6,D7,D8, D2005W, D2005N, D2006W, D2006N, D2007W, D2009W, D2010W, DXEW]
This report generates warnings that help you identify especially severe errors. Those are errors that can cause runtime failures (“showstoppers”), or erroneous results in your application.
Property access in read/write methods
This section reports locations where properties are referenced in read/write methods, like for example:
…
property MyProp : integer read GetMyProp write SetMyProp;
…
function TMyClass.GetMyProp : integer;
begin
Result := MyProp; // error, correct is: Result := FMyProp;
end;
procedure TMyClass.SetMyProp2(Value : integer);
begin
MyProp := Value; // error, correct is: FMyProp := Value;
end;
These sorts of errors can cause infinite recursion.
Ambiguous unit references
This sections lists identifiers with ambiguous unit references.
Consider this example:
program MyProg;
uses
A, B;
begin
writeln(‘Value=’+TheValue);
end.
unit A;
interface
const
TheValue = ‘Hello’;
implementation
end.
unit B;
interface
const
TheValue = ‘Goodbye’;
implementation
end.
What will be the output from the program? In this case, it will be “Goodbye”, because the last unit listed in the uses clause will have precedence.
The reference to TheValue is ambiguous or unclear, so it will be listed in this report section. Consider what happens if originally only unit “A” was listed in the uses clause. Then the output would be “Hello”. If then maybe another programmer without any sense of danger will add “B” to the uses clause, the output will be changed.
You should prefix the reference, like “B.TheValue”, to avoid any uncertainty.
See also:
General Reports
|