I maintain a Delphi component that has to run in several Delphi versions. In the last few versions I have noticed a behavior change.
The following code gives a warning in Delphi 10.1, and compiles fine in Delphi 10.2:
[dcc32 Warning] asdf.pas(1179): W1035 Return value of function 'TSomeClass.SomeFunc' might be undefined
function TSomeClass.SomeFunc(objc: TObject; const xD: array of string): integer;
var
s: string;
i: Integer;
begin
try
repeat
s := ReadLn;
// more code here
for i := 0 to High(xD) do
begin
if s = xD[i] then
begin
// Result := 0;
exit;
end;
end;
// more code here
until False;
finally
Result := 0;
end;
end;
The following code gives a hint in Delphi 10.2, and compiles fine in Delphi 10.1:
[dcc32 Hint] asdf.pas(1179): H2077 Value assigned to 'TSomeClass.SomeFunc' never used
function TSomeClass.SomeFunc(objc: TObject; const xD: array of string): integer;
var
s: string;
i: Integer;
begin
try
repeat
s := ReadLn;
// more code here
for i := 0 to High(xD) do
begin
if s = xD[i] then
begin
Result := 0;
exit;
end;
end;
// more code here
until False;
finally
Result := 0;
end;
end;
Was this behavior changed ?