-
In the following System.Console.WriteLine("Hello");
delegate int F(int x);
delegate int G((int, int) x);
delegate System.ValueTuple<int, int> H(int x);
delegate (int, int) I(int x);
class _ {
delegate (int, int) J(int x);
} As if to compensate for its uniqueness, it gives off tons of errors, actually:
... But not one that would help me understand how I angered the compiler. Just wondering. 😗 |
Beta Was this translation helpful? Give feedback.
Answered by
bernd5
Mar 13, 2023
Replies: 1 comment 2 replies
-
It seems to be a roslyn bug. delegate (int, int) I(int x); it is parsed as anonymous method expression with some missing parts. CompilationUnit()
.WithMembers(
List<MemberDeclarationSyntax>(
new MemberDeclarationSyntax[]{
GlobalStatement(
ExpressionStatement(
AnonymousMethodExpression()
.WithParameterList(
ParameterList(
SeparatedList<ParameterSyntax>(
new SyntaxNodeOrToken[]{
Parameter(
MissingToken(SyntaxKind.IdentifierToken))
.WithType(
PredefinedType(
Token(SyntaxKind.IntKeyword))),
Token(SyntaxKind.CommaToken),
Parameter(
MissingToken(SyntaxKind.IdentifierToken))
.WithType(
PredefinedType(
Token(SyntaxKind.IntKeyword)))})))
.WithBlock(
Block()
.WithOpenBraceToken(
MissingToken(SyntaxKind.OpenBraceToken))
.WithCloseBraceToken(
MissingToken(SyntaxKind.CloseBraceToken))))
.WithSemicolonToken(
MissingToken(SyntaxKind.SemicolonToken))),
GlobalStatement(
ExpressionStatement(
InvocationExpression(
IdentifierName("I"))
.WithArgumentList(
ArgumentList(
SeparatedList<ArgumentSyntax>(
new SyntaxNodeOrToken[]{
Argument(
PredefinedType(
Token(SyntaxKind.IntKeyword))),
MissingToken(SyntaxKind.CommaToken),
Argument(
IdentifierName("x"))})))))}))
.NormalizeWhitespace() |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
333fred
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems to be a roslyn bug.
it is parsed as anonymous method expression with some missing parts.
See: https://roslynquoter.azurewebsites.net/