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

Incorrect "CS0229 Ambiguity between" for partial prop with primary ctor, at design time only #76651

Open
jnm2 opened this issue Jan 7, 2025 · 0 comments
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@jnm2
Copy link
Contributor

jnm2 commented Jan 7, 2025

Version Used: 17.13.0 Preview 2.1

Thanks to @RoccoZero who reported that this issue has been happening for a few months.

  1. Building succeeds, though the error list and code editor show the errors.
  2. The repro requires separate source files.
  3. The repro disappears if the primary ctor is deleted.
.csproj
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
  </PropertyGroup>

</Project>
File 1
partial class PartialClass
{
    public partial string Prop => null;
}

partial class PartialClass(int p)
{
    public partial string Prop { get; }
}
File 2
class Repro
{
    void M(PartialClass c)
    {
        // ❌ CS0229 Ambiguity between 'PartialClass.Prop' and 'PartialClass.Prop'
        _ = c.Prop;
        _ = c.Prop; // Yep, error still here.
        _ = new PartialClass(0).Prop; // No error here!
        _ = c.Prop; // ERROR DISAPPEARS
        _ = c.Prop; // IT'S STILL GONE
    }
}

Image

Image

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant