Skip to content

Missing type arguments on method invocation with more than one type parameter produce unexpected syntax tree #67277

@jhinder

Description

@jhinder

Version Used: VS 2022 17.5.1 (4.5.0-6.23123.11)

Steps to Reproduce:
Inspect the syntax tree of the statement inside the method M.

class C
{
    void M<T1, T2>()
    {
        M<,>();
    }
}

SharpLab example

Expected Behavior:
The expression is an InvocationExpression with a GenericName and a TypeArgumentList, with some missing tokens and/or OmittedTypeArgument where appropriate, i.e. what you receive when you remove the comma or when you supply at least one type argument.
grafik

Actual Behavior:

  • M< is parsed as a LessThanExpression with a missing IdentifierToken on the RHS.
  • The comma is parsed as (missing) SemicolonToken with some trailing SkippedTokensTrivia.
  • >() is parsed as a GreaterThanExpression with a missing IdentifierToken on the LHS and an empty ParenthesizedExpression.
  • Five diagnostics are emitted: CS1002, CS1513, 3x CS1525.
    grafik

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions