dotnet/roslyn

Improve error recovery for explicit implementation lacking return type

Open

#61,563 opened on 2022年5月27日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)C# (4,257 forks)batch import
Area-CompilersConcept-Diagnostic Clarityhelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

Version Used: e6b5dd830f1b790bd80e62272129cc040d0a2fdc

Steps to Reproduce:

SharpLab

interface I
{
    void F();
}

class C : I
{
    F() { }
    I.F() { }
}

Expected Behavior: F() { } and I.F() { } both parse as ConstructorDeclaration, which results in a "Method must have a return type" diagnostic.

Actual Behavior: Only F() parses as a ConstructorDeclaration, which results in some not as useful parsing diagnostics for I.F():

error CS1519: Invalid token '(' in class, record, struct, or interface member declaration error CS8124: Tuple must contain at least two elements. error CS1519: Invalid token '{' in class, record, struct, or interface member declaration error CS1022: Type or namespace definition, or end-of-file expected

コントリビューターガイド