This commit is contained in:
Ivan Bondarev 2021-01-06 10:49:10 +01:00
parent bf7972e7e7
commit debd0ddee6
2 changed files with 14 additions and 1 deletions

13
TestSuite/lambdas10.pas Normal file
View file

@ -0,0 +1,13 @@
procedure p0<T>(o: T; p: byte->()) := p(2);
procedure p1() := exit;
var i: integer;
begin
var p2: ()->() := ()->Inc(i);
p0(0, b-> p1() );
p0(0, b-> p2.Invoke() );
p0(0, b-> p2() );
assert(i = 2);
end.

View file

@ -19980,7 +19980,7 @@ namespace PascalABCCompiler.TreeConverter
try
{
qq = convert_strong(ff.dereferencing_value);
if (qq is exit_procedure && stl.list.Count == 1)
if (qq is exit_procedure && stl.list.Count == 1 || qq is local_block_variable_reference && qq.type is compiled_type_node && (qq.type as compiled_type_node).compiled_type == typeof(Action))
{
// SSM #2172 27/06/20 - тело - это вызов exit
stl.list[0] = new procedure_call(ff, ff.source_context);