dotnet/roslyn

Improve error recovery for explicit implementation lacking return type

Open

#61,563 建立於 2022年5月27日

在 GitHub 查看
 (1 留言) (0 反應) (0 負責人)C# (4,257 fork)batch import
Area-CompilersConcept-Diagnostic Clarityhelp wanted

倉庫指標

Star
 (20,414 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 256 個 PR)

描述

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

貢獻者指南