【发布时间】:2020-08-28 15:12:48
【问题描述】:
我维护了一个必须在多个 Delphi 版本中运行的 Delphi 组件。 在最近的几个版本中,我注意到行为发生了变化。
以下代码在 Delphi 10.1 中给出警告,在 Delphi 10.2 中编译正常:
[dcc32 警告] asdf.pas(1179): W1035 函数“TSomeClass.SomeFunc”的返回值可能未定义
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;
以下代码在 Delphi 10.2 中给出了提示,在 Delphi 10.1 中编译良好:
[dcc32 Hint] asdf.pas(1179): H2077 分配给“TSomeClass.SomeFunc”的值从未使用过
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;
这种行为是否改变了?
【问题讨论】:
标签: delphi delphi-10.1-berlin delphi-10.2-tokyo