Skip to content

DoesNotReturn isn't enforced on local functions #52598

@jcouv

Description

@jcouv
using System;
using System.Diagnostics.CodeAnalysis;
#nullable enable
class Program
{
    [DoesNotReturn]
    static void Main()
    {
        Local();
        [DoesNotReturn] static void Local() { }; // expecting a warning, but got none
        [DoesNotReturn] static int Local1() => 1;  // expecting a warning but got none
    }
}

sharplab

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions