Skip to content

Commit 3231dcc

Browse files
committed
Moved back to comparing Text, added a test to demonstrate behavior.
1 parent 27e8523 commit 3231dcc

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/Compilers/CSharp/Portable/Parser/LanguageParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6471,7 +6471,7 @@ private bool IsPossibleCallingConvention(SyntaxToken asteriskToken)
64716471
// we'd have an error anyway, and it's more likely the user intended for it to be a
64726472
// function pointer convention than not.
64736473
// PROTOTYPE(func-ptr): refactor this out into a helper method to share with binding
6474-
switch (CurrentToken.ValueText)
6474+
switch (CurrentToken.Text)
64756475
{
64766476
case "cdecl":
64776477
case "managed":

src/Compilers/CSharp/Test/Syntax/Parsing/FunctionPointerTests.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,47 @@ public void Unterminated_10()
809809
EOF();
810810
}
811811

812+
[Fact]
813+
public void Unterminated_11()
814+
{
815+
UsingStatement("delegate* @cdecl>", options: TestOptions.RegularPreview,
816+
// (1,11): error CS1003: Syntax error, '<' expected
817+
// delegate* @cdecl>
818+
Diagnostic(ErrorCode.ERR_SyntaxError, "@cdecl").WithArguments("<", "").WithLocation(1, 11),
819+
// (1,17): error CS1003: Syntax error, ',' expected
820+
// delegate* @cdecl>
821+
Diagnostic(ErrorCode.ERR_SyntaxError, ">").WithArguments(",", ">").WithLocation(1, 17),
822+
// (1,18): error CS1002: ; expected
823+
// delegate* @cdecl>
824+
Diagnostic(ErrorCode.ERR_SemicolonExpected, "").WithLocation(1, 18));
825+
N(SyntaxKind.LocalDeclarationStatement);
826+
{
827+
N(SyntaxKind.VariableDeclaration);
828+
{
829+
N(SyntaxKind.FunctionPointerType);
830+
{
831+
N(SyntaxKind.DelegateKeyword);
832+
N(SyntaxKind.AsteriskToken);
833+
M(SyntaxKind.LessThanToken);
834+
M(SyntaxKind.ModifiedType);
835+
{
836+
M(SyntaxKind.IdentifierName);
837+
{
838+
M(SyntaxKind.IdentifierToken);
839+
}
840+
}
841+
M(SyntaxKind.GreaterThanToken);
842+
}
843+
N(SyntaxKind.VariableDeclarator);
844+
{
845+
N(SyntaxKind.IdentifierToken, "@cdecl");
846+
}
847+
}
848+
M(SyntaxKind.SemicolonToken);
849+
}
850+
EOF();
851+
}
852+
812853
[Fact]
813854
public void NoParamOrReturnTypes()
814855
{

0 commit comments

Comments
 (0)