This commit is contained in:
parent
ac9ada5557
commit
9bd8efce75
30
TestSuite/lambda_constructors.pas
Normal file
30
TestSuite/lambda_constructors.pas
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
var sss: string;
|
||||
|
||||
type
|
||||
t1 = class
|
||||
constructor;
|
||||
procedure p0 := exit;
|
||||
end;
|
||||
|
||||
t2 = class
|
||||
constructor(f: ()->()) := f();
|
||||
end;
|
||||
|
||||
constructor t1.Create;
|
||||
begin
|
||||
foreach var i in Arr(0) do
|
||||
begin
|
||||
var s := 'tt';
|
||||
new t2(()->
|
||||
begin
|
||||
var s2 := s;
|
||||
sss := s;
|
||||
end);
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
t1.Create.p0;
|
||||
assert(sss = 'tt');
|
||||
end.
|
||||
27
TestSuite/lambda_constructors2.pas
Normal file
27
TestSuite/lambda_constructors2.pas
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
type TBase = class
|
||||
o: object;
|
||||
constructor;
|
||||
begin
|
||||
o := new object;
|
||||
end;
|
||||
end;
|
||||
|
||||
TDer = class(TBase)
|
||||
constructor;
|
||||
begin
|
||||
var obj := o;
|
||||
var f: ()->() := ()->assert(obj <> nil);
|
||||
f();
|
||||
end;
|
||||
constructor (i: integer);
|
||||
begin
|
||||
var obj := o;
|
||||
var f: ()->() := ()->assert(obj <> nil);
|
||||
f();
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
new TDer;
|
||||
new TDer(2);
|
||||
end.
|
||||
|
|
@ -17657,7 +17657,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
statements_list stl = new statements_list(get_location(_statement_list), get_location_with_check(_statement_list.left_logical_bracket), get_location_with_check(_statement_list.right_logical_bracket));
|
||||
convertion_data_and_alghoritms.statement_list_stack_push(stl);
|
||||
|
||||
for (var i = 0; i < _statement_list.subnodes.Count; i++) // SSM 13.10.16 - поменял т.к. собираюсь менять узлы в процессе обхода
|
||||
{
|
||||
statement syntax_statement = _statement_list.subnodes[i];
|
||||
|
|
@ -17669,7 +17668,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (stl.statements.Count > 0 && stl.statements[0] is basic_function_call && i == 2)
|
||||
{
|
||||
base_function_call bfc = stl.statements[0] as basic_function_call;
|
||||
if (bfc.type != null && bfc.type.name.Contains("<>local_variables_class") && (semantic_statement is compiled_constructor_call || semantic_statement is common_constructor_call)
|
||||
if (bfc.type != null && bfc.type.name.Contains("<>local_variables_class") &&
|
||||
(semantic_statement is compiled_constructor_call && !(semantic_statement as compiled_constructor_call).new_obj_awaited() || semantic_statement is common_constructor_call && !(semantic_statement as common_constructor_call).new_obj_awaited())
|
||||
&& !context.converted_func_stack.Empty && context.converted_func_stack.top() is common_method_node && (context.converted_func_stack.top() as common_method_node).is_constructor)
|
||||
stl.statements.AddElementFirst(semantic_statement);
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue