Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adjusting wording for ErrorCode.ERR_NoConvToIDisp #73559

Closed
AlekseyTs opened this issue May 17, 2024 · 0 comments · Fixed by #74311
Closed

Consider adjusting wording for ErrorCode.ERR_NoConvToIDisp #73559

AlekseyTs opened this issue May 17, 2024 · 0 comments · Fixed by #74311
Assignees
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. New Feature - RefStructInterfaces untriaged Issues and PRs which have not yet been triaged by a lead
Milestone

Comments

@AlekseyTs
Copy link
Contributor

        [Fact]
        public void Using_06()
        {
            var src = @"
interface IMyDisposable
{
    void Dispose();
}

ref struct S2 : IMyDisposable
{
    public void Dispose()
    {
    }
}

class C
{
    static void Main()
    {
        Test(new S2(), null);
    }

    static void Test<T>(T t, IMyDisposable s) where T : IMyDisposable, allows ref struct
    {
        using (t)
        {
        }

        using (s)
        {
        }
    }
}
";
            var comp = CreateCompilation(src, targetFramework: s_targetFrameworkSupportingByRefLikeGenerics, options: TestOptions.ReleaseExe);

            // PROTOTYPE(RefStructInterfaces): Should we adjust wording for the error? Ref struct implement interfaces, but not convertible to them.  
            comp.VerifyDiagnostics(
                // (23,16): error CS1674: 'T': type used in a using statement must be implicitly convertible to 'System.IDisposable'.
                //         using (t)
                Diagnostic(ErrorCode.ERR_NoConvToIDisp, "t").WithArguments("T").WithLocation(23, 16),
                // (27,16): error CS1674: 'IMyDisposable': type used in a using statement must be implicitly convertible to 'System.IDisposable'.
                //         using (s)
                Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s").WithArguments("IMyDisposable").WithLocation(27, 16)
                );
        }

Observed: See PROTOTYPE comment in the test

@AlekseyTs AlekseyTs self-assigned this May 17, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label May 17, 2024
@jaredpar jaredpar added the Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. label May 20, 2024
@jaredpar jaredpar added this to the 17.12 milestone May 20, 2024
AlekseyTs added a commit to AlekseyTs/roslyn that referenced this issue Jul 9, 2024
@AlekseyTs AlekseyTs added the 4 - In Review A fix for the issue is submitted for review. label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. New Feature - RefStructInterfaces untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
2 participants