From 045da8df413ca999443fc0b97a2fbd1b004b8273 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Wed, 14 Oct 2020 18:36:15 +0000 Subject: [PATCH 01/11] Fix property parsing when it contains parantheses --- src/Compilers/VisualBasic/Portable/Parser/Parser.vb | 6 +++++- .../Test/Syntax/Parser/ParserRegressionTests.vb | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Compilers/VisualBasic/Portable/Parser/Parser.vb b/src/Compilers/VisualBasic/Portable/Parser/Parser.vb index f1f1ab8d26c8c..a7bd66011f9ea 100644 --- a/src/Compilers/VisualBasic/Portable/Parser/Parser.vb +++ b/src/Compilers/VisualBasic/Portable/Parser/Parser.vb @@ -4186,7 +4186,11 @@ checkNullable: ' TODO - GreenSepList knows its error count. Expose it instead of recomputing it. If propertyParameters.Count = 0 Then Dim unexpected = ResyncAt({SyntaxKind.AsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.EqualsToken}) - closeParen = closeParen.AddTrailingSyntax(unexpected) + If unexpected.Count > 0 Then + closeParen = closeParen.AddTrailingSyntax(unexpected, ERRID.ERR_ExpectedEOS) + Else + closeParen = closeParen.AddTrailingSyntax(unexpected) + End If End If optionalParameters = SyntaxFactory.ParameterList(openParen, propertyParameters, closeParen) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index 0ce46fbf1763e..2d71a80e0adb6 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -934,4 +934,15 @@ End Enum Assert.Equal(Syntax.InternalSyntax.Scanner.BadTokenCountLimit, tree.GetDiagnostics().Where(Function(d) d.Code = ERRID.ERR_IllegalChar).Count()) End Sub + + Public Sub ParseTrailingTextAfterPropertyWithParentheses() + ParseAndVerify(, + + +) + End Sub End Class From 77822c19537533020764d3026ac135c5ab78d5ba Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Fri, 23 Oct 2020 09:09:53 +0200 Subject: [PATCH 02/11] Update ParserRegressionTests.vb --- .../VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index 2d71a80e0adb6..e8e9c6f98876f 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -938,11 +938,13 @@ End Enum Public Sub ParseTrailingTextAfterPropertyWithParentheses() ParseAndVerify(, + ) End Sub End Class From d760d300e3257b327b5fdaac1696149f15ee449a Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Fri, 23 Oct 2020 20:30:50 +0200 Subject: [PATCH 03/11] Remove redundant else --- src/Compilers/VisualBasic/Portable/Parser/Parser.vb | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Compilers/VisualBasic/Portable/Parser/Parser.vb b/src/Compilers/VisualBasic/Portable/Parser/Parser.vb index a7bd66011f9ea..4f890e56b0257 100644 --- a/src/Compilers/VisualBasic/Portable/Parser/Parser.vb +++ b/src/Compilers/VisualBasic/Portable/Parser/Parser.vb @@ -4188,8 +4188,6 @@ checkNullable: Dim unexpected = ResyncAt({SyntaxKind.AsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.EqualsToken}) If unexpected.Count > 0 Then closeParen = closeParen.AddTrailingSyntax(unexpected, ERRID.ERR_ExpectedEOS) - Else - closeParen = closeParen.AddTrailingSyntax(unexpected) End If End If From 7d183f256867bf3904b507aa237aa1e57af5943d Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Wed, 4 Nov 2020 12:05:00 +0200 Subject: [PATCH 04/11] Remove unnecessary resync --- src/Compilers/VisualBasic/Portable/Parser/Parser.vb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Compilers/VisualBasic/Portable/Parser/Parser.vb b/src/Compilers/VisualBasic/Portable/Parser/Parser.vb index 4f890e56b0257..128f4e83f3794 100644 --- a/src/Compilers/VisualBasic/Portable/Parser/Parser.vb +++ b/src/Compilers/VisualBasic/Portable/Parser/Parser.vb @@ -4181,16 +4181,6 @@ checkNullable: If CurrentToken.Kind = SyntaxKind.OpenParenToken Then propertyParameters = ParseParameters(openParen, closeParen) - - ' If we blow up on the parameters try to resume on the AS, =, or Implements - ' TODO - GreenSepList knows its error count. Expose it instead of recomputing it. - If propertyParameters.Count = 0 Then - Dim unexpected = ResyncAt({SyntaxKind.AsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.EqualsToken}) - If unexpected.Count > 0 Then - closeParen = closeParen.AddTrailingSyntax(unexpected, ERRID.ERR_ExpectedEOS) - End If - End If - optionalParameters = SyntaxFactory.ParameterList(openParen, propertyParameters, closeParen) Else If ident.ContainsDiagnostics Then From 7cf0fbc16fe7959b3d6448e08b5b15841c2ba8db Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Wed, 4 Nov 2020 12:12:18 +0200 Subject: [PATCH 05/11] Use AssertTheseDiagnostics --- .../Test/Syntax/Parser/ParserRegressionTests.vb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index e8e9c6f98876f..1639c120c5fb7 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -936,15 +936,15 @@ End Enum Public Sub ParseTrailingTextAfterPropertyWithParentheses() - ParseAndVerify( + Class C Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer End Class -]]>, - - - -) + + ) + CompilationUtils.AssertTheseDiagnostics(compilation, ) End Sub End Class From 75dc6c5d261b881f7ac85f6e906ef6496b9d9a00 Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Wed, 4 Nov 2020 12:58:38 +0200 Subject: [PATCH 06/11] Update ParserRegressionTests.vb --- .../VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index 1639c120c5fb7..5bd465a4c9515 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -937,14 +937,14 @@ End Enum Public Sub ParseTrailingTextAfterPropertyWithParentheses() Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40( - + Class C Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer End Class - ) +) CompilationUtils.AssertTheseDiagnostics(compilation, ) End Sub End Class From e6515aa726a4a3ac62fb5ba678409291361cc397 Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Wed, 4 Nov 2020 15:23:44 +0200 Subject: [PATCH 07/11] Add expected errors --- .../Test/Syntax/Parser/ParserRegressionTests.vb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index 5bd465a4c9515..7d4d71418d1bc 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -945,6 +945,14 @@ Class C End Class ) - CompilationUtils.AssertTheseDiagnostics(compilation, ) + CompilationUtils.AssertTheseDiagnostics(compilation, + +BC30205: End of statement expected. +Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow + ~~~~~~ +BC30205: End of statement expected. +Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer + ~~~~ +) End Sub End Class From bbcff97f49f47c19d75460c457013b2d7fd72ac7 Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Wed, 4 Nov 2020 15:26:38 +0200 Subject: [PATCH 08/11] Add more tests --- .../VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index 7d4d71418d1bc..6de8ed50175ca 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -942,6 +942,10 @@ End Enum Class C Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer + + Public ReadOnly Property NumberOfResult3() ' With comment - no errors. + Public ReadOnly Property NumberOfResult4() _ + As Integer ' No error with line continuation. End Class ) From 096a5053313b43d09bbcda64006ba40833cdb27a Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Wed, 4 Nov 2020 18:26:25 +0200 Subject: [PATCH 09/11] Fix test --- .../Test/Syntax/Parser/ParserRegressionTests.vb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index 6de8ed50175ca..57ac174bcf1ba 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -952,11 +952,11 @@ End Class CompilationUtils.AssertTheseDiagnostics(compilation, BC30205: End of statement expected. -Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow - ~~~~~~ + Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow + ~~~~~~ BC30205: End of statement expected. -Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer - ~~~~ + Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer + ~~~~ ) End Sub End Class From 4fa28eba7c35c573115b09c8288cdb030e425d1d Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Thu, 5 Nov 2020 12:53:33 +0200 Subject: [PATCH 10/11] Add more tests based on feedback --- .../Test/Syntax/Parser/ParserRegressionTests.vb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index 57ac174bcf1ba..581302d6dab4e 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -942,9 +942,12 @@ End Enum Class C Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer + Public ReadOnly Property NumberOfResult3() UnexpectedToken ' With comment. + Public ReadOnly Property NumberOfResult4() UnexpectedToken _ + As Integer ' with line continuation and comment. - Public ReadOnly Property NumberOfResult3() ' With comment - no errors. - Public ReadOnly Property NumberOfResult4() _ + Public ReadOnly Property NumberOfResult5() ' With comment - no errors. + Public ReadOnly Property NumberOfResult6() _ As Integer ' No error with line continuation. End Class @@ -957,6 +960,10 @@ BC30205: End of statement expected. BC30205: End of statement expected. Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer ~~~~ + Public ReadOnly Property NumberOfResult3() UnexpectedToken ' With comment. + ~~~~~~~~~~~~~~~ + Public ReadOnly Property NumberOfResult4() UnexpectedToken _ + ~~~~~~~~~~~~~~~ ) End Sub End Class From 0a06dbb16ec6281e2765cea492079129f56aaf19 Mon Sep 17 00:00:00 2001 From: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Date: Thu, 5 Nov 2020 14:12:59 +0200 Subject: [PATCH 11/11] Update ParserRegressionTests.vb --- .../VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb index 581302d6dab4e..e10774ec82a94 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/ParserRegressionTests.vb @@ -960,8 +960,10 @@ BC30205: End of statement expected. BC30205: End of statement expected. Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer ~~~~ +BC30205: End of statement expected. Public ReadOnly Property NumberOfResult3() UnexpectedToken ' With comment. ~~~~~~~~~~~~~~~ +BC30205: End of statement expected. Public ReadOnly Property NumberOfResult4() UnexpectedToken _ ~~~~~~~~~~~~~~~ )