This commit is contained in:
Ivan Bondarev 2021-05-16 11:52:32 +02:00
parent abec09d436
commit 46a4f5d766
2 changed files with 28 additions and 2 deletions

24
TestSuite/foreach9.pas Normal file
View file

@ -0,0 +1,24 @@
var i: integer;
type
t1 = record
private function InitA: integer;
begin
Inc(i);
end;
public a := InitA;
public b: integer;
public constructor(b: integer) := self.b := b;
end;
begin
var l := new List<t1>;
l += new t1(2);
l += new t1(3);
foreach var o in l do
;
assert(i = 2);
end.

View file

@ -161,8 +161,10 @@ namespace PascalABCCompiler.TreeConverter
check_for_type_allowed(tn, get_location(_foreach_stmt.type_name));
check_using_static_class(tn, get_location(_foreach_stmt.type_name));
}
context.close_var_definition_list(tn, null);
if (tn.is_value_type && !tn.is_standard_type)
context.close_var_definition_list(tn, new default_operator_node(tn, foreachVariable.location));
else
context.close_var_definition_list(tn, null);
}
if (/*!(foreachVariable.type is compiled_generic_instance_type_node) &&*/ !sys_coll_ienum) // SSM 16.09.18 - закомментировал это ограничение для фиксации бага #1184