diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 80ef1d85b..5c42b65e6 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 = "2"; - public const string Revision = "2374"; + public const string Revision = "2376"; 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 f7043ef6c..def3bcfd3 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=2 -%REVISION%=2374 +%REVISION%=2376 %MINOR%=6 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index ef7f1c72d..36baf3e43 100644 Binary files a/Localization/DefaultLang.resources and b/Localization/DefaultLang.resources differ diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index a55e62937..7948428c5 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -2,7 +2,7 @@ // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 // Machine: DESKTOP-G8V08V4 -// DateTime: 07.03.2020 10:31:43 +// DateTime: 08.03.2020 11:15:34 // UserName: ????????? // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index 1e36b3d09..43400d7fa 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -1550,15 +1550,6 @@ object_type { var cd = NewObjectType((class_attribute)$1, $2, $3 as named_type_reference_list, $4 as where_definition_list, $5 as class_body_list, @$); $$ = cd; - /*var tt = cd.DescendantNodes().OfType().Where(cld => cld.keyword == class_keyword.Record); - if (tt.Count()>0) - { - foreach (var ttt in tt) - { - var sc = ttt.source_context; - parsertools.AddErrorFromResource("NESTED_RECORD_DEFINITIONS_ARE_FORBIDDEN", new LexLocation(sc.begin_position.line_num, sc.begin_position.column_num-1, sc.end_position.line_num, sc.end_position.column_num, sc.FileName)); - } - }*/ } ; diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index dd7a62de0..a26db962e 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: DESKTOP-G8V08V4 -// DateTime: 07.03.2020 10:31:44 +// DateTime: 08.03.2020 11:15:35 // UserName: ????????? // Input file @@ -3973,15 +3973,6 @@ public partial class GPPGParser: ShiftReduceParser().Where(cld => cld.keyword == class_keyword.Record); - if (tt.Count()>0) - { - foreach (var ttt in tt) - { - var sc = ttt.source_context; - parsertools.AddErrorFromResource("NESTED_RECORD_DEFINITIONS_ARE_FORBIDDEN", new LexLocation(sc.begin_position.line_num, sc.begin_position.column_num-1, sc.end_position.line_num, sc.end_position.column_num, sc.FileName)); - } - }*/ } break; case 284: // record_type -> tkRecord, optional_base_classes, optional_where_section, diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index 6e21d7eac..754eb08bd 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -263,5 +263,6 @@ script= + diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 47e09446b..05d709c18 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.6.2.2374 +3.6.2.2376 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 776045c89..77cd70e5e 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.6.2.2374' +!define VERSION '3.6.2.2376' diff --git a/SyntaxVisitors/YieldVisitors/MarkMethodHasYieldVisitor.cs b/SyntaxVisitors/YieldVisitors/MarkMethodHasYieldVisitor.cs index 13ca68b41..450b838fe 100644 --- a/SyntaxVisitors/YieldVisitors/MarkMethodHasYieldVisitor.cs +++ b/SyntaxVisitors/YieldVisitors/MarkMethodHasYieldVisitor.cs @@ -12,6 +12,27 @@ using PascalABCCompiler.Errors; namespace SyntaxVisitors { + public class CheckArrayRecordInitializersVisitor : WalkingVisitorNew + { + //procedure_definition PD; + public static CheckArrayRecordInitializersVisitor New + { + get { return new CheckArrayRecordInitializersVisitor(); } + } + public override void visit(function_lambda_definition ld) + { + // пропустить всё + } + public override void visit(var_def_statement vd) + { + if (vd.inital_value is array_const) + throw new SyntaxVisitorError("FUNCTION_WITH_YIELD_CANNOT_CONTAIN_OLDSTYLE_ARRAY_INITIALIZERS", vd.inital_value.source_context); + if (vd.inital_value is record_const) + throw new SyntaxVisitorError("FUNCTION_WITH_YIELD_CANNOT_CONTAIN_OLDSTYLE_RECORD_INITIALIZERS", vd.inital_value.source_context); + } + + } + public class MarkMethodHasYieldAndCheckSomeErrorsVisitor : WalkingVisitorNew { private bool HasYields = false; @@ -75,6 +96,8 @@ namespace SyntaxVisitors throw new SyntaxVisitorError("FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_INHERITED_CALLS", FirstInheritedIdent.First().source_context); } } + + CheckArrayRecordInitializersVisitor.New.ProcessNode(pd); } /*if (pd.has_yield) diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index a4603c6ea..23f1495f5 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -2595,6 +2595,11 @@ type constructor (c: string; n, w: integer; f: string) := (Comment, Num, Width, Fmt) := (c, n, w, f); end; +type + [AttributeUsage(AttributeTargets.Class)] + PCUNotRestoreAttribute = class(System.Attribute) + public constructor := exit; + end; ///-- function InternalRange(l,r: integer): IntRange; diff --git a/TestSuite/errors/err0353_arr_rec_init_in_yield.pas b/TestSuite/errors/err0353_arr_rec_init_in_yield.pas new file mode 100644 index 000000000..da40e5521 --- /dev/null +++ b/TestSuite/errors/err0353_arr_rec_init_in_yield.pas @@ -0,0 +1,14 @@ +type Rec = record + i: integer; +end; + +function f1: sequence of word; +begin + //var r: Rec := (i: 2); + var a: array of array of integer := ((1,2),(3)); + yield 0; +end; + +begin + +end. \ No newline at end of file diff --git a/TestSuite/errors/err0354_arr_rec_init_in_yield.pas b/TestSuite/errors/err0354_arr_rec_init_in_yield.pas new file mode 100644 index 000000000..2cde3a09e --- /dev/null +++ b/TestSuite/errors/err0354_arr_rec_init_in_yield.pas @@ -0,0 +1,14 @@ +type Rec = record + i: integer; +end; + +function f1: sequence of word; +begin + var r: Rec := (i: 2); + //var a: array of array of integer := ((1,2),(3)); + yield 0; +end; + +begin + +end. \ No newline at end of file diff --git a/bin/Lng/Eng/SyntaxTreeVisitorsErrors.dat b/bin/Lng/Eng/SyntaxTreeVisitorsErrors.dat index 13862f627..4d7ff087a 100644 --- a/bin/Lng/Eng/SyntaxTreeVisitorsErrors.dat +++ b/bin/Lng/Eng/SyntaxTreeVisitorsErrors.dat @@ -12,6 +12,8 @@ FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_TRY_EXCEPT_FINALLY=Functions with yield can FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_NESTED_SUBROUTINES=Functions with yield cannot contain nested subrotines or be nested FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_LOCAL_TYPE_DEFINITIONS=Functions with yield cannot contain local type definitions FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_INHERITED_CALLS=Functions with yield cannot contain calls of inherited methods +FUNCTION_WITH_YIELD_CANNOT_CONTAIN_OLDSTYLE_ARRAY_INITIALIZERS=Functions with yield cannot contain Delphi-style array initializers +FUNCTION_WITH_YIELD_CANNOT_CONTAIN_OLDSTYLE_RECORD_INITIALIZERS=Functions with yield cannot contain Delphi-style record initializers YIELDS_INSIDE_WITH_ARE_ILLEGAL=with statement cannot contain yields YIELDSEQUENCES_INSIDE_WITH_ARE_ILLEGAL=with statement cannot contain yield sequence LAMBDA_EXPRESSIONS_CANNOT_CONTAIN_YIELD=Lambda-expressions cannot contain yields diff --git a/bin/Lng/Rus/SyntaxTreeVisitorsErrors.dat b/bin/Lng/Rus/SyntaxTreeVisitorsErrors.dat index bf85736bd..9a733a07e 100644 --- a/bin/Lng/Rus/SyntaxTreeVisitorsErrors.dat +++ b/bin/Lng/Rus/SyntaxTreeVisitorsErrors.dat @@ -12,6 +12,8 @@ FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_TRY_EXCEPT_FINALLY=Функции с yield FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_NESTED_SUBROUTINES=Функции с yield не могут содержать вложенные подпрограммы и сами быть вложенными FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_LOCAL_TYPE_DEFINITIONS=Функции с yield не могут содержать локальные определения типов FUNCTIONS_WITH_YIELDS_CANNOT_CONTAIN_INHERITED_CALLS=Функции с yield не могут содержать вызовы inherited методов +FUNCTION_WITH_YIELD_CANNOT_CONTAIN_OLDSTYLE_ARRAY_INITIALIZERS=Функции с yield не могут содержать инициализаторы массивов в стиле Delphi +FUNCTION_WITH_YIELD_CANNOT_CONTAIN_OLDSTYLE_RECORD_INITIALIZERS=Функции с yield не могут содержать инициализаторы записей в стиле Delphi YIELDS_INSIDE_WITH_ARE_ILLEGAL=Оператор yield запрещен внутри with YIELDSEQUENCES_INSIDE_WITH_ARE_ILLEGAL=Оператор yield sequence запрещен внутри with LAMBDA_EXPRESSIONS_CANNOT_CONTAIN_YIELD=Лямбда-выражения не могут содержать yield