bug fix #592
This commit is contained in:
parent
4a9f3171bd
commit
6e177e0c90
19
TestSuite/lambdas5.pas
Normal file
19
TestSuite/lambdas5.pas
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
type
|
||||||
|
t1=class
|
||||||
|
|
||||||
|
function f1(aX,aY:Single):=byte(2);
|
||||||
|
|
||||||
|
constructor;
|
||||||
|
begin
|
||||||
|
|
||||||
|
var MAng := 0;
|
||||||
|
var NP2 := new byte[1];
|
||||||
|
NP2.Fill(i->self.f1(i,MAng));
|
||||||
|
assert(NP2[0] = 2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
new t1;
|
||||||
|
end.
|
||||||
|
|
@ -287,7 +287,8 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
if (lst.statements[0] is basic_function_call)
|
if (lst.statements[0] is basic_function_call)
|
||||||
{
|
{
|
||||||
base_function_call bfc = lst.statements[0] as basic_function_call;
|
base_function_call bfc = lst.statements[0] as basic_function_call;
|
||||||
|
if (bfc.type != null && bfc.type.name.Contains("<>local_variables_class"))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16668,11 +16668,21 @@ namespace PascalABCCompiler.TreeConverter
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
statement_node semantic_statement = convert_strong(syntax_statement);
|
statement_node semantic_statement = convert_strong(syntax_statement);
|
||||||
|
bool lambda_init_code = false;
|
||||||
|
if (semantic_statement is basic_function_call)
|
||||||
|
{
|
||||||
|
base_function_call bfc = semantic_statement as basic_function_call;
|
||||||
|
if (bfc.type != null && bfc.type.name.Contains("<>local_variables_class"))
|
||||||
|
lambda_init_code = true;
|
||||||
|
}
|
||||||
if (semantic_statement != null)
|
if (semantic_statement != null)
|
||||||
{
|
{
|
||||||
|
if (context.allow_inherited_ctor_call && !lambda_init_code)
|
||||||
|
stl.statements.AddElementFirst(semantic_statement);
|
||||||
|
else
|
||||||
stl.statements.AddElement(semantic_statement);
|
stl.statements.AddElement(semantic_statement);
|
||||||
}
|
}
|
||||||
|
if (!lambda_init_code)
|
||||||
context.allow_inherited_ctor_call = false;
|
context.allow_inherited_ctor_call = false;
|
||||||
}
|
}
|
||||||
catch (Errors.Error ex)
|
catch (Errors.Error ex)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue