diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index e5fce85af..07a62b8db 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 = "4"; public const string Build = "2"; - public const string Revision = "1786"; + public const string Revision = "1787"; 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 df423d734..4877b560c 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=4 -%REVISION%=1786 %COREVERSION%=2 +%REVISION%=1787 +%MINOR%=4 %MAJOR%=3 diff --git a/Errors/Errors.cs b/Errors/Errors.cs index 4b93824c3..635316485 100644 --- a/Errors/Errors.cs +++ b/Errors/Errors.cs @@ -152,8 +152,30 @@ namespace PascalABCCompiler.Errors source_context = _source_context; if (source_context != null && source_context.FileName != null) base.fileName = source_context.FileName; + if (source_context == null && _bad_node != null) // искать source_context у Parentов + { + var bn = _bad_node; + + do + { + bn = bn.Parent; + if (bn != null && bn.source_context != null) + { + source_context = bn.source_context; + if (source_context.FileName != null) + base.fileName = source_context.FileName; + break; + } + } while (bn != null); + + } bad_node = _bad_node; } + public SyntaxError(string Message, string fileName, PascalABCCompiler.SyntaxTree.syntax_tree_node bad_node) + : this(Message, fileName, bad_node.source_context, bad_node) { } + public SyntaxError(string Message, PascalABCCompiler.SyntaxTree.syntax_tree_node bad_node) + : this(Message, null, bad_node.source_context, bad_node) { } + public override string ToString() { string snode=""; diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index e229e1aac..ac56779c5 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 365bdb2ad..f5963ee02 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.4.2.1786' +!define VERSION '3.4.2.1787' diff --git a/SyntaxVisitors/SyntaxTreeVisitorsErrors.cs b/SyntaxVisitors/SyntaxTreeVisitorsErrors.cs index 6f9be837f..998a91403 100644 --- a/SyntaxVisitors/SyntaxTreeVisitorsErrors.cs +++ b/SyntaxVisitors/SyntaxTreeVisitorsErrors.cs @@ -28,6 +28,11 @@ namespace SyntaxVisitors public SyntaxVisitorError(string resourcestring, SourceContext sc, params object[] values): base(StringResources.Get(resourcestring),"",sc,null) { + } + public SyntaxVisitorError(string resourcestring, PascalABCCompiler.SyntaxTree.syntax_tree_node bad_node) + : base(StringResources.Get(resourcestring), "", bad_node.source_context, bad_node) + { + } } } diff --git a/SyntaxVisitors/YieldVisitors/MarkMethodHasYieldVisitor.cs b/SyntaxVisitors/YieldVisitors/MarkMethodHasYieldVisitor.cs index 23c76acbe..ca742f5f9 100644 --- a/SyntaxVisitors/YieldVisitors/MarkMethodHasYieldVisitor.cs +++ b/SyntaxVisitors/YieldVisitors/MarkMethodHasYieldVisitor.cs @@ -43,7 +43,7 @@ namespace SyntaxVisitors base.visit(ws); } - + ident IdResult = null; public override void visit(procedure_definition pd) { //this.CurrentMethod = pd; @@ -68,6 +68,19 @@ namespace SyntaxVisitors } } + /*if (pd.has_yield) + { + var dn = pd.DescendantNodes().OfType().Where(id => id.name.ToLower() == "result").FirstOrDefault(); + if (dn != null) + throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_RESULT", dn); + }*/ + + if (pd.has_yield) + { + if (IdResult != null) + throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_RESULT", IdResult); + } + var innerPds = pd.DescendantNodes().OfType(); if (pd.has_yield && innerPds.Count() > 0 @@ -89,6 +102,7 @@ namespace SyntaxVisitors } HasYields = false; + IdResult = null; MethodsStack.Pop(); @@ -97,15 +111,16 @@ namespace SyntaxVisitors public override void visit(ident id) { + if (MethodsStack.Count > 0 && id.name.ToLower() == "result") + { + IdResult = id; + //throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_RESULT", id.source_context); + } //if (CurrentMethod == null || !HasYields) if (MethodsStack.Count == 0 || !HasYields) { return; } - if (id.name.ToLower() == "result") - { - throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_RESULT", id.source_context); - } } public override void visit(dot_node dn) diff --git a/bin/Lng/Rus/SemanticErrors_ib.dat b/bin/Lng/Rus/SemanticErrors_ib.dat index b6ab65ab2..2535966af 100644 --- a/bin/Lng/Rus/SemanticErrors_ib.dat +++ b/bin/Lng/Rus/SemanticErrors_ib.dat @@ -139,7 +139,7 @@ GENERIC_RECORDS_CANNOT_HAVE_EXPLICIT_LAYOUT=Генерик-записи не м ATTRIBUTE_CANNOT_BE_GENERIC=Атрибуты не могут быть генерик-классами EXTERNAL_METHOD_CANNOT_BE_DECLARED_IN_GENERIC_TYPE=external-методы нельзя описывать в генерик-классах EXTERNAL_METHOD_CANNOT_BE_GENERIC=external-методы не могут быть генериками -WHERE_SPECIFIER_MISMATCH=Несоответствие спецификатора whеre спецификатору where базового классе​ +WHERE_SPECIFIER_MISMATCH=Несоответствие спецификатора whеre спецификатору where базового класса %PREFIX%=COMPILATIONERROR_ UNIT_MODULE_EXPECTED_LIBRARY_FOUND=Ожидался модуль, а встречена библиотека ASSEMBLY_{0}_READING_ERROR=Ошибка при чтении сборки '{0}'