+2
[C108] "Nested With ..." does not detect some cases
As I was playing around with C108, I came across the following code snippet, where FixInsight 2015.11upd2 does not detect the nested with statements.
program Project4;
{$APPTYPE CONSOLE}
{$R *.res}
type
TA = class
NA: string;
end;
TB = class
NB: String;
end;
var
A: TA;
B: TB;
begin
A := TA.Create;
B := TB.Create;
with A, B do <-- would expect a C108 warning here. I consider this a "nested with" too
WriteLn(NA, NB);
with A do
with B do <-- would expect a C108 warning here
WriteLn(NA, NB);
end. Maybe it's fixed in a later version, but upd6 throws some false positives, which is why I won't roll it out in our company yet.
Customer support service by UserEcho
It does detect the second "with", when the code is copied into a .pas file. It doesn't detect the second with in a dpr as in the above example.
The first case:
with A, B do <-- would expect a C108 warning here. I consider this a "nested with" too WriteLn(NA, NB);
is unfortunately becoming important for us. We have installed a rule that fails the build when people add new nested with statements, but now, developers are smart ;), new statements creep into the code, which is not what we intend ...