Skip to content

Partially closed generic type name is not parsed correctly when first type argument is missing #71379

@jhinder

Description

@jhinder

Version Used: VS 17.8.2

Steps to Reproduce:

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

public class G<T1, T2>;

SharpLab repro

Expected Behavior:
The type argument list is parsed correctly, with the first type argument being reported as missing (with an appropriate error diagnostic, possibly CS1031 "Type expected"?).

Actual Behavior:
The angled brackets cause the expressions to be parsed as greater than/less than expressions, which leads to an unexpected syntax tree with lots of misleading diagnostics.
(The trees of both expressions look quite similar to that from #67277.)

grafik

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions