diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 6c8b00b90..7e7fb198d 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 = "6"; public const string Build = "3"; - public const string Revision = "2585"; + public const string Revision = "2586"; 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 c044c13ee..35b40d516 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=6 -%REVISION%=2585 %COREVERSION%=3 +%REVISION%=2586 +%MINOR%=6 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 45fa5108d..27e350988 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.6.3.2585 +3.6.3.2586 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 48b68ce86..4a376621f 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.6.3.2585' +!define VERSION '3.6.3.2586' diff --git a/SyntaxTree/tree/TreeHelper.cs b/SyntaxTree/tree/TreeHelper.cs index 99955a28e..20cc80365 100644 --- a/SyntaxTree/tree/TreeHelper.cs +++ b/SyntaxTree/tree/TreeHelper.cs @@ -1871,6 +1871,7 @@ namespace PascalABCCompiler.SyntaxTree public partial class semantic_check_sugared_statement_node { public bool visited = false; + public override string ToString() => "semantic_check_sugared(" + string.Join(", ",lst) + ")"; } public partial class var_deconstructor_parameter diff --git a/SyntaxTreeConverters/StandardSyntaxConverter.cs b/SyntaxTreeConverters/StandardSyntaxConverter.cs index d9b886219..61fc6d3d3 100644 --- a/SyntaxTreeConverters/StandardSyntaxConverter.cs +++ b/SyntaxTreeConverters/StandardSyntaxConverter.cs @@ -78,7 +78,7 @@ namespace PascalABCCompiler.SyntaxTreeConverters cv.ProcessNode(root); cv.Output(@"Light1.txt");*/ - /*try + try { root.visit(new SimplePrettyPrinterVisitor(@"d:\\zzz1.txt")); } @@ -86,7 +86,7 @@ namespace PascalABCCompiler.SyntaxTreeConverters { System.IO.File.AppendAllText(@"d:\\zzz1.txt",e.Message); - }*/ + } #endif diff --git a/SyntaxVisitors/PatternsVisitors/PatternsDesugaringVisitor.cs b/SyntaxVisitors/PatternsVisitors/PatternsDesugaringVisitor.cs index f48de1063..888797e97 100644 --- a/SyntaxVisitors/PatternsVisitors/PatternsDesugaringVisitor.cs +++ b/SyntaxVisitors/PatternsVisitors/PatternsDesugaringVisitor.cs @@ -99,7 +99,7 @@ namespace SyntaxVisitors.PatternsVisitors private int generalVariableCounter = 0; private int successVariableCounter = 0; private int labelVariableCounter = 0; - private int deconstructParamVariableCounter = 0; + private static int deconstructParamVariableCounter = 0; private int matchExprVariableCounter = 0; private if_node _previousIf; @@ -207,6 +207,7 @@ namespace SyntaxVisitors.PatternsVisitors // Замена выражения match with на новое несахарное поддерево и его обход ReplaceUsingParent(matchWith, desugaredMatchWith); visit(desugaredMatchWith); + typeChecks.Clear(); // SSM исправление ошибки #2276 } private int num = 0; @@ -246,29 +247,32 @@ namespace SyntaxVisitors.PatternsVisitors // stn = stn.Parent; //if (stn is procedure_definition pd && pd.has_yield) // SSM 11/07/20 Надо сделать обход с переименованием!!! Сейчас and не работает в yield + ... is A(var a1) //{ + // SSM 14/07/20 var dict = new Dictionary(StringComparer.InvariantCultureIgnoreCase); // bool - надо ли начинать renaming - var l = new List(); - var pp = isPatternExpr.right?.parameters; - if (pp != null) + + var l = new List(); + var pp = isPatternExpr.right?.parameters; + if (pp != null) + { + foreach (var p in pp) { - foreach (var p in pp) + if (p is var_deconstructor_parameter vdp) { - if (p is var_deconstructor_parameter vdp) - { - var idClone = vdp.identifier.TypedClone(); - var idNew = vdp.identifier.TypedClone(); - idNew.name = GenerateNewName(idNew.name); - var vs = new var_statement(idClone, idNew, idClone.source_context); - // проверять, что имя не начинается с $ и если начинается, то ошибка - уже переименовывали такое же! - if (vdp.identifier.name.StartsWith("$")) - throw new SyntaxVisitorError("Повторное объявление", vdp.identifier.source_context); - dict.Add(vdp.identifier.name, new StrBool(idNew.name,false)); - //vdp.identifier.name = idNew.name; // в следующем цикле переименую - l.Add(vs); - } + var idClone = vdp.identifier.TypedClone(); + var idNew = vdp.identifier.TypedClone(); + idNew.name = GenerateNewName(idNew.name); + var vs = new var_statement(idClone, idNew, idClone.source_context); + // проверять, что имя не начинается с $ и если начинается, то ошибка - уже переименовывали такое же! + if (vdp.identifier.name.StartsWith("$")) // SSM 14/07/20 + throw new SyntaxVisitorError("Повторное объявление", vdp.identifier.source_context); + dict.Add(vdp.identifier.name, new StrBool(idNew.name,false)); + //vdp.identifier.name = idNew.name; // в следующем цикле переименую + l.Add(vs); } } + } + // SSM 14/07/20 // подниматься пока выражение syntax_tree_node ex = isPatternExpr; syntax_tree_node ex1 = ex; @@ -307,24 +311,24 @@ namespace SyntaxVisitors.PatternsVisitors } - var stat = GetAscendant(isPatternExpr); - if (stat is if_node ifn) + var stat = GetAscendant(isPatternExpr); + if (stat is if_node ifn) + { + //l.Add(ifn.then_body); + if (!(ifn.then_body is statement_list)) { - //l.Add(ifn.then_body); - if (!(ifn.then_body is statement_list)) - { - ifn.then_body = new statement_list(ifn.then_body); - } - (ifn.then_body as statement_list).list.InsertRange(0, l); - } - else - { - l.Insert(0, stat); - foreach (var x in l) - x.Parent = stat.Parent; - var stl = stat.Parent as statement_list; - stl.ReplaceInList(stat, l); + ifn.then_body = new statement_list(ifn.then_body); } + (ifn.then_body as statement_list).list.InsertRange(0, l); + } + else + { + l.Insert(0, stat); + foreach (var x in l) + x.Parent = stat.Parent; + var stl = stat.Parent as statement_list; + stl.ReplaceInList(stat, l); + } //} @@ -920,17 +924,24 @@ namespace SyntaxVisitors.PatternsVisitors } private semantic_check_sugared_statement_node GetMatchedExpressionCheck(expression matchedExpression) - => new semantic_check_sugared_statement_node(SemanticCheckType.MatchedExpression, new List() { matchedExpression }); + { + return new semantic_check_sugared_statement_node(SemanticCheckType.MatchedExpression, new List() { matchedExpression }); + } - private semantic_check_sugared_statement_node GetTypeCompatibilityCheck(is_pattern_expr expression) => - new semantic_check_sugared_statement_node(SemanticCheckType.MatchedExpressionAndType, new List() { expression.left, (expression.right as deconstructor_pattern).type }); + private semantic_check_sugared_statement_node GetTypeCompatibilityCheck(is_pattern_expr expression) + { + return new semantic_check_sugared_statement_node(SemanticCheckType.MatchedExpressionAndType, new List() { expression.left, (expression.right as deconstructor_pattern).type }); + } - private semantic_check_sugared_statement_node GetTypeCompatibilityCheck(expression expression1, expression expression2) => - new semantic_check_sugared_statement_node(SemanticCheckType.MatchedExpressionAndExpression, new List() { expression1, expression2 }); - - private semantic_check_sugared_statement_node GetTypeCompatibilityCheck(expression tuple, int32_const length) => - new semantic_check_sugared_statement_node(SemanticCheckType.MatchedTuple, new List() { tuple, length }); + private semantic_check_sugared_statement_node GetTypeCompatibilityCheck(expression expression1, expression expression2) + { + return new semantic_check_sugared_statement_node(SemanticCheckType.MatchedExpressionAndExpression, new List() { expression1, expression2 }); + } + private semantic_check_sugared_statement_node GetTypeCompatibilityCheck(expression tuple, int32_const length) + { + return new semantic_check_sugared_statement_node(SemanticCheckType.MatchedTuple, new List() { tuple, length }); + } private bool IsNestedIfWithExtendedIs(if_node ifNode) { var parent = ifNode.Parent; diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 12c1152f6..4795fec7a 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -4625,7 +4625,8 @@ end; function Arr(params a: array of T): array of T; begin Result := new T[a.Length]; - System.Array.Copy(a, Result, a.Length); + if a.Length > 0 then + System.Array.Copy(a, Result, a.Length); end; function Arr(a: sequence of T): array of T;