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

贡献者指南