I tried with Delphi XE and I got Not Responding while compiling. Does it work in your computer or is there something wrong with the function?
function Test(const FileName: string;
const Force: boolean = false): boolean;
var
IsAllowed: boolean;
begin
result := false;
if FileExists(FileName) then
begin
try
if (Force) then
begin
result := false;
exit;
end;
finally
if IsAllowed then
DeleteFile(FileName);
end;
try
result := true;
except
result := false;
end;
end;
end;
It compiles on my computer. Though I get the warning W1036 Variable ‘IsAllowed’ might not have been initialized.
Update: I can reproduce the hang when I include Windows in the uses clause.
Subbmitted to Quality Central: QC93806.
It looks like a bug; you should report it in the Quality Central.
Update 2: Minimal case which reproducibly hangs the compiler: