diff --git a/.gitattributes b/.gitattributes index 261e4bf4e9..edf5b30efb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18839,6 +18839,7 @@ tests/webtbs/tw38718.pp svneol=native#text/pascal tests/webtbs/tw38733.pp svneol=native#text/pascal tests/webtbs/tw38766.pp svneol=native#text/plain tests/webtbs/tw38802.pp svneol=native#text/pascal +tests/webtbs/tw38833.pp svneol=native#text/plain tests/webtbs/tw3893.pp svneol=native#text/plain tests/webtbs/tw3898.pp svneol=native#text/plain tests/webtbs/tw3899.pp svneol=native#text/plain diff --git a/compiler/nflw.pas b/compiler/nflw.pas index e1c4bef90a..adc5008dd1 100644 --- a/compiler/nflw.pas +++ b/compiler/nflw.pas @@ -2734,10 +2734,10 @@ implementation begin result:=right; right:=nil; - end; + end { if the finally block contains no code, we can kill it and just return the try part } - if has_no_code(right) and not(assigned(third)) and not(implicitframe) then + else if has_no_code(right) and not(assigned(third)) and not(implicitframe) then begin result:=left; left:=nil; diff --git a/tests/webtbs/tw38833.pp b/tests/webtbs/tw38833.pp new file mode 100644 index 0000000000..06759133e2 --- /dev/null +++ b/tests/webtbs/tw38833.pp @@ -0,0 +1,18 @@ +program EmptyTryFinally1; + +{$mode delphi} +{$apptype console} + +var + finallyrun: boolean; +begin + finallyrun:=false; + try + // Empty try statement block + finally + WriteLn('I should actually visible . . .'); // but I'm not + finallyrun:=true; + end; + if not finallyrun then + halt(1); +end.