我收到了一个编译器警告,但我不理解:
procedure Test;
var
Var1: Integer;
begin
while True do
begin
try
if System.Random > 0.5 then
begin
ShowMessage('Skipping');
continue; // If I remove this line, the warning goes away
end;
Var1:=6;
except on
E:Exception do
begin
ShowMessage('Error');
raise;
end;
end;
ShowMessage(IntToStr(Var1)); // Compiler warning on this line
end;
end;
当我在Delphi 2010中编译此代码时,会出现以下警告信息:
[DCC Warning] OnlineClaimManagerMainU.pas(554): W1036 变量 'Var1' 可能未被初始化
如果我删除对 'continue' 的调用,则警告消失。
同时,如果我删除try/except子句(并保留continue),则警告也会消失。
那么,在没有初始化Var1的情况下,程序如何执行到相关代码行呢?