dotnet/roslyn

Cascaded diagnostic when label not found.

Open

#5 243 ouverte le 15 sept. 2015

Voir sur GitHub
 (0 commentaires) (1 réaction) (1 assigné)C# (4 257 forks)batch import
Area-CompilersBugConcept-Diagnostic ClarityLanguage-C#help wanted

Métriques du dépôt

Stars
 (20 414 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (256 PRs mergées en 30 j)

Description

Here are some examples demonstrating that flow analysis reports redundant errors when labels are not found. In each case the compiler reports that a label was not found, but then also reports a reachability error that would not be an error if a label had been found. The later error should be suppressed.

class Program
{
    static void Main(string[] args)
    {
        int s = 23;
        switch (s)
        {
            case 21:
                goto case 1;
                // redundant error "Control cannot fall through from one case label ('case 21:') to another
            case 23:
                goto default;
                // redundant error "Control cannot fall out of switch from final case label ('case 23:')"
        }
    }

    static int M()
    {
        goto foo;
        // redundant error "not all code paths return a value"
    }
}

Guide contributeur