-
Notifications
You must be signed in to change notification settings - Fork 833
Closed
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone
Description
Trying to assign a protected property at the constructor call of an inherit clause fails with an accessibility error.
Repro steps
public class Foo
{
protected string Value { get; set; } = "";
}type Bar() =
// FS0629
inherit Foo(Value = "Fails")Expected behavior
The F# snippet compiles and Value is assigned.
Actual behavior
The F# snippet fails with FS0629 "Method 'set_Value' is not accessible from this code location."
Known workarounds
Either assign the property on a do clause or at the constructor call of an object expression.
type Bar() as this =
inherit Foo()
// OK
do this.Value <- "OK"
// OK as well
{ new Foo(Value = "OK") with (* ... *) }Related information
- .NET 6.0.203
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Type
Projects
Status
Done