Skip to content

Update error message of parsMultipleAccessibilitiesForGetSet - #15424

Merged
0101 merged 12 commits into
dotnet:mainfrom
nojaf:visibility-property-get-set
Jun 20, 2023
Merged

Update error message of parsMultipleAccessibilitiesForGetSet#15424
0101 merged 12 commits into
dotnet:mainfrom
nojaf:visibility-property-get-set

Conversation

@nojaf

Copy link
Copy Markdown
Contributor

Fixes#15423

@nojaf
nojaf requested a review from a team as a code ownerJune 16, 2023 15:10
@vzarytovskii

Copy link
Copy Markdown
Member

I don't think that's right.
Private setter, public getter scenario is very common one. Or am I missing something (looking from my phone)?

@T-Gro

Copy link
Copy Markdown
Member

Please see the comment here #15423 (comment) .

The error is only in case of mixing "outer" and "inner" declaration of visibility for a property.
Getter and setter can have different accessibilities just fine.

@KevinRansom

This comment was marked as duplicate.

KevinRansom

This comment was marked as duplicate.

@KevinRansomKevinRansom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nojaf - I believe this is not the correct fix.

typeFoo()=memberf.Xwithinternal get (key1, key2)=trueandprivateset(key1,key2)value =()memberinternalf.Ywith get (key1,key2)=trueandprivateset(key1,key2)value =()

If you do not specify the visibility of the property F# allows you specify individual visibilities for the getter and setter, as shown in the X property of the repro.

The reason F# needs this behaviour is for C# interop which also allows, distinct visibilities for the getter or setter,
E.g.

publicstringShowSomething{set;privateget;}="Some text value";

The Y property has an error because if you specify the visibility of the property, then you are not allowed to specify the visibility of the getters and setters.

I think improving the error message would have been better. Something like, "When the visibility for a property is specified, setting the visibility of the set or get method is not allowed."

@nojaf

Copy link
Copy Markdown
ContributorAuthor

Thanks everyone, I was indeed confused about all of this.
I've updated the error message as @KevinRansom suggested.

@nojaf
nojaf requested a review from KevinRansomJune 19, 2023 12:38
@nojafnojaf changed the title Raise error when the accessibility of the getter and setter don't match.Update error message of parsMultipleAccessibilitiesForGetSetJun 19, 2023
@KevinRansom
KevinRansom enabled auto-merge (squash) June 19, 2023 19:16
auto-merge was automatically disabled June 20, 2023 11:26

Head branch was pushed to by a user without write access

@0101
0101 merged commit a22ab7c into dotnet:mainJun 20, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Multiple accessibilities given for property getter or setter is not raised for property

5 participants

@nojaf@vzarytovskii@T-Gro@KevinRansom@0101