From d3ffb2c93cd2f3e52093003dc88029d078f7e2c6 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Fri, 22 Feb 2019 19:11:56 +0300 Subject: [PATCH] fix #1761 --- Parsers/PascalABCParserNewSaushkin/ABCPascal.cs | 6 +++--- Parsers/PascalABCParserNewSaushkin/ABCPascal.y | 2 ++ Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs | 8 +++++--- Parsers/PascalABCParserNewSaushkin/PABC.ymc | 1 + TestSuite/errors/err0308.pas | 3 +++ bin/Lng/Eng/PascalABCParser.dat | 3 ++- bin/Lng/Rus/PascalABCParser.dat | 3 ++- 7 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 TestSuite/errors/err0308.pas diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 876fb17a3..394b11175 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -1,9 +1,9 @@ // // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 -// Machine: DESKTOP-IF20NRO -// DateTime: 1/25/2019 9:59:06 AM -// UserName: FatCow +// Machine: DESKTOP-G8V08V4 +// DateTime: 22.02.2019 19:09:57 +// UserName: ????????? // GPLEX input file // GPLEX frame file // diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index da2142861..411dd868c 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -3209,6 +3209,8 @@ new_expr field_in_unnamed_object : identifier tkAssign relop_expr { + if ($3 is nil_const) + parsertools.AddErrorFromResource("NIL_IN_UNNAMED_OBJECT",@$); $$ = new name_assign_expr($1,$3,@$); } | relop_expr diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index a3571f024..3d4ee93fe 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -1,9 +1,9 @@ // (see accompanying GPPGcopyright.rtf) // GPPG version 1.3.6 -// Machine: DESKTOP-IF20NRO -// DateTime: 1/25/2019 9:59:07 AM -// UserName: FatCow +// Machine: DESKTOP-G8V08V4 +// DateTime: 22.02.2019 19:09:58 +// UserName: ????????? // Input file // options: no-lines gplex @@ -5423,6 +5423,8 @@ public partial class GPPGParser: ShiftReduceParser identifier, tkAssign, relop_expr { + if (ValueStack[ValueStack.Depth-1].ex is nil_const) + parsertools.AddErrorFromResource("NIL_IN_UNNAMED_OBJECT",CurrentLocationSpan); CurrentSemanticValue.ob = new name_assign_expr(ValueStack[ValueStack.Depth-3].id,ValueStack[ValueStack.Depth-1].ex,CurrentLocationSpan); } break; diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index ef4b878e6..40d249a73 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -240,5 +240,6 @@ script= + diff --git a/TestSuite/errors/err0308.pas b/TestSuite/errors/err0308.pas new file mode 100644 index 000000000..4bfc6808e --- /dev/null +++ b/TestSuite/errors/err0308.pas @@ -0,0 +1,3 @@ +begin + var x := new class(p := nil); +end. \ No newline at end of file diff --git a/bin/Lng/Eng/PascalABCParser.dat b/bin/Lng/Eng/PascalABCParser.dat index cebdd79b4..742291266 100644 --- a/bin/Lng/Eng/PascalABCParser.dat +++ b/bin/Lng/Eng/PascalABCParser.dat @@ -71,4 +71,5 @@ EXTENDED_INDEXED_PROPERTIES=Extended indexed properties are not realized ATTRIBUTE_REDECLARED=This attribute has been already applied to type STATIC_PROPERTIES_CANNOT_HAVE_ATTRBUTE_{0}=Static properties cannot have attribute '{0}' RESULT_IDENT_NOT_EXPECTED_IN_THIS_CONTEXT=Result identifier is not allowed in this context -NESTED_RECORD_DEFINITIONS_ARE_ARE_FORBIDDEN=Nested record definitions are forbidden \ No newline at end of file +NESTED_RECORD_DEFINITIONS_ARE_ARE_FORBIDDEN=Nested record definitions are forbidden +NIL_IN_UNNAMED_OBJECT=Anonymous class field cannot be initialized by nil constant \ No newline at end of file diff --git a/bin/Lng/Rus/PascalABCParser.dat b/bin/Lng/Rus/PascalABCParser.dat index 1adcb05a8..2a583ad9b 100644 --- a/bin/Lng/Rus/PascalABCParser.dat +++ b/bin/Lng/Rus/PascalABCParser.dat @@ -72,4 +72,5 @@ TWO_STRING_LITERALS_IN_SUCCESSION=Две литеральные строковы ATTRIBUTE_REDECLARED=Повторное применение атрибута STATIC_PROPERTIES_CANNOT_HAVE_ATTRBUTE_{0}=Статические свойства не могут иметь атрибут '{0}' RESULT_IDENT_NOT_EXPECTED_IN_THIS_CONTEXT=Имя Result недопустимо в этом контексте -NESTED_RECORD_DEFINITIONS_ARE_FORBIDDEN=Вложенные описания записей запрещены \ No newline at end of file +NESTED_RECORD_DEFINITIONS_ARE_FORBIDDEN=Вложенные описания записей запрещены +NIL_IN_UNNAMED_OBJECT=Поле анонимного класса не может инициализироваться константой nil \ No newline at end of file