From 673f9bc1496528b8e478e0727eda4504d14350a8 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Tue, 18 Jun 2019 21:19:46 +0300 Subject: [PATCH] bug fix #1531 --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 ++-- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/lambda_capture_for_counter_1.pas | 14 ++++++++++++++ TestSuite/lambda_capture_foreach_counter_1.pas | 12 ++++++++++++ .../LambdaExpressions/LambdaResultTypeInferrer.cs | 10 ++++++++++ .../TreeConversion/syntax_tree_visitor.cs | 2 +- 7 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 TestSuite/lambda_capture_for_counter_1.pas create mode 100644 TestSuite/lambda_capture_foreach_counter_1.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index cbe4305ed..fd37935d1 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "5"; public const string Build = "0"; - public const string Revision = "2114"; + public const string Revision = "2117"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index d00b6194a..3b0fda0b0 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=0 -%REVISION%=2114 %MINOR%=5 +%REVISION%=2117 +%COREVERSION%=0 %MAJOR%=3 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 70ee72969..647126cc4 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.5.0.2114' +!define VERSION '3.5.0.2117' diff --git a/TestSuite/lambda_capture_for_counter_1.pas b/TestSuite/lambda_capture_for_counter_1.pas new file mode 100644 index 000000000..f68225fb1 --- /dev/null +++ b/TestSuite/lambda_capture_for_counter_1.pas @@ -0,0 +1,14 @@ +begin + Arr(0).Select( + i -> + begin + Result := 0; + for var i2 := 3 to 4 do + begin + //Print(i2); + var a := i2; + Print(a) + end; + end + ); +end. \ No newline at end of file diff --git a/TestSuite/lambda_capture_foreach_counter_1.pas b/TestSuite/lambda_capture_foreach_counter_1.pas new file mode 100644 index 000000000..d356d7e82 --- /dev/null +++ b/TestSuite/lambda_capture_foreach_counter_1.pas @@ -0,0 +1,12 @@ +begin + Arr(0).Select( + i-> + begin + Result := 0; + foreach var i2 in Arr(1,2) do + begin + var a := i2; + end; + end + ); +end. \ No newline at end of file diff --git a/TreeConverter/LambdaExpressions/LambdaResultTypeInferrer.cs b/TreeConverter/LambdaExpressions/LambdaResultTypeInferrer.cs index 24a697a11..090553738 100644 --- a/TreeConverter/LambdaExpressions/LambdaResultTypeInferrer.cs +++ b/TreeConverter/LambdaExpressions/LambdaResultTypeInferrer.cs @@ -69,6 +69,16 @@ namespace TreeConverter.LambdaExpressions syntaxTreeVisitor.visit(varStmt); } + public override void visit(PascalABCCompiler.SyntaxTree.for_node fn) + { + syntaxTreeVisitor.visit(fn); + } + + public override void visit(PascalABCCompiler.SyntaxTree.foreach_stmt fn) + { + syntaxTreeVisitor.visit(fn); + } + // Patterns public override void visit(desugared_deconstruction _desugared_deconstruction) { diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index b03ad2923..1b9b1ac05 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -19438,7 +19438,7 @@ namespace PascalABCCompiler.TreeConverter { visit(procDecl); } - catch + catch (Exception e) { context.remove_lambda_function(procDecl.proc_header.name.meth_name.name, true); throw;