dotnet/roslyn

Unclear error message for pointer types in pattern matching

开放

#43,339 创建于 2020年4月14日

 (0 条评论) (0 个反应) (0 位负责人)C# (4,257 个派生)batch import
Area-CompilersConcept-Diagnostic ClarityFeature - Pattern Matchinghelp wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

unsafe class C
{
    static void Main()
    {
        int* ptr = null;
        _ = ptr is var (x); // error CS8521: Pattern-matching is not permitted for pointer types.
        _ = ptr is var y; // valid code
    }
}

The error message shown above doesn't mention anything about parenthesized patterns, despite the fact that that's the only difference between those two lines. We can make this clearer.

贡献者指南