fix #1737
This commit is contained in:
parent
f014935bac
commit
88e8b54b73
45
TestSuite/lambda_closure_static_fields.pas
Normal file
45
TestSuite/lambda_closure_static_fields.pas
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
type
|
||||
t2 = class
|
||||
public static sv := 0;
|
||||
end;
|
||||
|
||||
t1 = class
|
||||
|
||||
public static sv := 0;
|
||||
public sv2: integer;
|
||||
|
||||
public static procedure p1;
|
||||
begin
|
||||
var v := 0;
|
||||
var p: ()->() := ()->begin
|
||||
|
||||
v := v;
|
||||
sv := 5;
|
||||
t2.sv := 5;
|
||||
end;
|
||||
p;
|
||||
end;
|
||||
|
||||
public procedure p2;
|
||||
begin
|
||||
var v := 0;
|
||||
var p: ()->() := ()->begin
|
||||
v := v;
|
||||
sv := 6;
|
||||
t2.sv := 6;
|
||||
sv2 := 2;
|
||||
end;
|
||||
p;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
t1.p1;
|
||||
assert(t1.sv = 5);
|
||||
assert(t2.sv = 5);
|
||||
var o := new t1;
|
||||
o.p2;
|
||||
assert(t1.sv = 6);
|
||||
assert(t2.sv = 6);
|
||||
assert(o.sv2 = 2);
|
||||
end.
|
||||
|
|
@ -312,7 +312,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
|
||||
if (
|
||||
_capturedVarsClassDefs[nextNodeWhereVarsAreCaptured.ScopeIndex]
|
||||
.AssignNodeForUpperClassFieldInitialization == null)
|
||||
.AssignNodeForUpperClassFieldInitialization == null && !(ClassField != null && ClassField.IsStatic))
|
||||
{
|
||||
var fieldType =
|
||||
SyntaxTreeBuilder.BuildSimpleType(upperScopeWhereVarsAreCapturedClass.type_name.name);
|
||||
|
|
|
|||
|
|
@ -19275,12 +19275,12 @@ namespace PascalABCCompiler.TreeConverter
|
|||
public override void visit(SyntaxTree.function_lambda_definition _function_lambda_definition)
|
||||
{
|
||||
#if DEBUG
|
||||
if (lambdaProcessingState == LambdaProcessingState.ClosuresProcessingPhase)
|
||||
/*if (lambdaProcessingState == LambdaProcessingState.ClosuresProcessingPhase)
|
||||
{
|
||||
var s = new string (' ',ccc)+"begin " + _function_lambda_definition.lambda_name + " " + _function_lambda_definition.parameters.expressions[0] + "\n";
|
||||
ccc += 2;
|
||||
System.IO.File.AppendAllText("d:\\bb3.txt", s);
|
||||
}
|
||||
}*/
|
||||
#endif
|
||||
MaybeConvertFunctionLambdaDefinitionToProcedureLambdaDefinition(_function_lambda_definition);
|
||||
|
||||
|
|
@ -19444,12 +19444,12 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
stflambda.Pop();
|
||||
#if DEBUG
|
||||
if (lambdaProcessingState == LambdaProcessingState.ClosuresProcessingPhase)
|
||||
/*if (lambdaProcessingState == LambdaProcessingState.ClosuresProcessingPhase)
|
||||
{
|
||||
ccc -= 2;
|
||||
var s = new string(' ', ccc) + "end " + _function_lambda_definition.lambda_name + " " + _function_lambda_definition.parameters.expressions[0] + "\n";
|
||||
System.IO.File.AppendAllText("d:\\bb3.txt", s);
|
||||
}
|
||||
}*/
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue