diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 6798c93a6..707b7961c 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 = "2150"; + public const string Revision = "2151"; 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 bb860dfc4..9d542cb42 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=0 -%REVISION%=2150 %MINOR%=5 +%REVISION%=2151 +%COREVERSION%=0 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index 97f133009..1966e8b69 100644 Binary files a/Localization/DefaultLang.resources and b/Localization/DefaultLang.resources differ diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index bdf9a5502..b6a3390ef 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.5.0.2150' +!define VERSION '3.5.0.2151' diff --git a/SyntaxTree/tree/TreeHelper.cs b/SyntaxTree/tree/TreeHelper.cs index 010204bd7..ce750d458 100644 --- a/SyntaxTree/tree/TreeHelper.cs +++ b/SyntaxTree/tree/TreeHelper.cs @@ -332,6 +332,11 @@ namespace PascalABCCompiler.SyntaxTree { get { return new statement_list(); } } + + public override string ToString() + { + return "begin " + list.Select(st=>st is empty_statement ? "" : st.ToString()+"; ").Aggregate((s,x)=>s+x)+ "end"; + } //-- List members end } @@ -564,7 +569,7 @@ namespace PascalABCCompiler.SyntaxTree sb.Append(" := "); sb.Append(inital_value.ToString()); } - sb.Append("; "); + //sb.Append("; "); return sb.ToString(); } } @@ -761,14 +766,15 @@ namespace PascalABCCompiler.SyntaxTree if (name != null) sb.Append(name.ToString()); else - sb.Append("NONAME"); + sb.Append(""); if (template_args != null) sb.Append("<" + template_args.ToString() + ">"); if (parameters != null) sb.Append("(" + parameters.ToString() + ")"); - sb.Append(";"); + if (name != null) + sb.Append(";"); if (this.proc_attributes != null) foreach (var pa in this.proc_attributes.proc_attributes) sb.Append(" " + pa.ToString() + " "); @@ -1669,7 +1675,11 @@ namespace PascalABCCompiler.SyntaxTree { public override string ToString() { - return "" + this._ident_list.ToString() + " -> lambda_body"; + var s = this._ident_list.ToString(); + if (_ident_list.Count != 1) + s = "(" + s + ")"; + var b = this.proc_body.ToString(); + return "" + s + " -> "+b; } } @@ -1893,5 +1903,14 @@ namespace PascalABCCompiler.SyntaxTree this.source_context = sc; } } + + public partial class empty_statement + { + public override string ToString() => "<>"; + } + public partial class modern_proc_type + { + public override string ToString() => ""; + } } diff --git a/TestSuite/lambda_3_levels_a.pas b/TestSuite/lambda_3_levels_a.pas new file mode 100644 index 000000000..e6c8407a4 --- /dev/null +++ b/TestSuite/lambda_3_levels_a.pas @@ -0,0 +1,19 @@ +begin + var a := 1; + + var l0: procedure := + ()-> + begin + var l1: procedure := ()->Assert(777=777); + + var l2: integer->()->() := + i-> + begin + Assert(666=666); + Result := ()-> Assert(a+i=8); + end; + l1; + l2(7)(); + end; + l0(); +end. \ No newline at end of file diff --git a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs index b4ab3c5d5..0c5786371 100644 --- a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs +++ b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs @@ -544,6 +544,14 @@ namespace TreeConverter.LambdaExpressions.Closure private void AddReferencesToIdentInLambda(type_declaration upperScopeWhereVarsAreCapturedClass, CapturedVariablesTreeNode scope, string varName, syntax_tree_node syntaxTreeNodeWithVarDeclaration, dot_node substDotNode, bool nestedLambda) { +/*#if DEBUG + var pp = scope.ToString().IndexOf("TreeNode"); + var ss = scope.ToString().Remove(0, pp + 8).Replace("Scope"," "); + var cn = ""; + if (scope.ChildNodes.Count>0) + cn = "Childs: "+ scope.ChildNodes.Aggregate("",(s, x) => s + x.ScopeIndex.ToString() + " "); + System.IO.File.AppendAllText("d:\\w.txt", "AddR enter: " + ss + scope.ScopeIndex + " " + cn + "" +scope.CorrespondingSyntaxTreeNode + "\n"); +#endif*/ for (var i = 0; i < scope.ChildNodes.Count; i++) { if (!(scope.ChildNodes[i] is CapturedVariablesTreeNodeLambdaScope)) @@ -579,6 +587,10 @@ namespace TreeConverter.LambdaExpressions.Closure if (!_substitutions.ContainsKey(substKey)) { +/*#if DEBUG + System.IO.File.AppendAllText("d:\\w.txt", "1 substitutions.Add: " + substKey + " " + substDotNode + "\n"); +#endif*/ + _substitutions.Add(substKey, substDotNode); } @@ -634,19 +646,26 @@ namespace TreeConverter.LambdaExpressions.Closure scope.ChildNodes[0].CorrespondingSyntaxTreeNode); if (!_substitutions.ContainsKey(substKey)) { +/*#if DEBUG + System.IO.File.AppendAllText("d:\\w.txt", "2 substitutions.Add: " + substKey + " " + substDotNode + "\n"); +#endif*/ + _substitutions.Add(substKey, substDotNode1); } - AddReferencesToIdentInLambda(_capturedVarsClassDefs[scopeAsLambda.ScopeIndexOfClassWhereLambdaWillBeAddedAsMethod.Value].ClassDeclaration, scopeAsLambda.ChildNodes[0], varName, syntaxTreeNodeWithVarDeclaration, substDotNode1, true); } else { - AddReferencesToIdentInLambda(upperScopeWhereVarsAreCapturedClass, scope.ChildNodes[0], varName, syntaxTreeNodeWithVarDeclaration, substDotNode, nestedLambda); + // SSM 25.06.19 fix #1988 - заменил ошибочное scope.ChildNodes[0] на scope.ChildNodes[i] + AddReferencesToIdentInLambda(upperScopeWhereVarsAreCapturedClass, scope.ChildNodes[i], varName, syntaxTreeNodeWithVarDeclaration, substDotNode, nestedLambda); } } } +/*#if DEBUG + System.IO.File.AppendAllText("d:\\w.txt", "AddR exit: " + scope.ScopeIndex+"\n"); +#endif*/ } - + private void VisitTreeAndBuildClassDefinitions(CapturedVariablesTreeNode currentNode) { var variablesFromThisScopeWhichWereCaptured = currentNode