diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index ec74cc427..3a9527190 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -10290,7 +10290,10 @@ namespace PascalABCCompiler.NETGenerator { if (!ExitProcedureCall) ExitLabel = il.DefineLabel(); - il.Emit(OpCodes.Br, ExitLabel); + if (!safe_block) + il.Emit(OpCodes.Br, ExitLabel); + else + il.Emit(OpCodes.Leave, ExitLabel); ExitProcedureCall = true; } diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index b9a18c3c5..40091a97a 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -1964,7 +1964,7 @@ begin on e: System.Exception do begin Result := nil; - Exit; + //Exit; end; end; end;