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

Warn if function shadows union case #16062

Closed
wants to merge 3 commits into from
Closed

Warn if function shadows union case #16062

wants to merge 3 commits into from

Conversation

Martin521
Copy link
Contributor

Fix for #15559

@Martin521 Martin521 requested a review from a team as a code owner September 29, 2023 17:49
@Martin521
Copy link
Contributor Author

@Martin521 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree

@vzarytovskii
Copy link
Member

Since it's a potentially quite common case (shadowing in general, and this case in particular), I personally don't think it should be an on-by-default warning even if guarded by language version, since it can break a lot of builds out of the blue.

I think instead, we should have a set of warnings which we can suggest to help people avoid dubious code (this warning included).

Thoughts @T-Gro @KevinRansom @dotnet/fsharp-team-msft

It might be a me thing, will be happy to be proven wrong.

@Martin521
Copy link
Contributor Author

Yes, tbh I did not expect any intentional shadowing of this particular type, but then found 3 in the compiler code base. All sort of weird though.

@vzarytovskii
Copy link
Member

I still think it shouldn't be warning which is on by default, even for next version. Many if not majority of F# projects treat warnings as errors, this will mean that people will get compilation errors just by updating SDK, we try to avoid it as much as possible.

Will wait for others' opinions though.

@smoothdeveloper
Copy link
Contributor

smoothdeveloper commented Oct 1, 2023

My gut feeling is that the warning by default rubs against the shadowing idioms.

I'd personally prefer it is a non default warning.

edit: the shadowing can be intentional, and it is generally possible to access the union case by using the type qualifier.

@vzarytovskii
Copy link
Member

My gut feeling is that the warning by default rubs against the shadowing idioms.

I'd personally prefer it is a non default warning.

edit: the shadowing can be intentional, and it is generally possible to access the union case by using the type qualifier.

Yep, have pretty much the same thoughts.

@Martin521
Copy link
Contributor Author

Shall I then close this PR in favor of #16064?

(Fix for #15559, improve error reporting)
to ProvidedTypes.fs in vs integration tests
@abonie
Copy link
Member

abonie commented Oct 5, 2023

Shall I then close this PR in favor of #16064?

I suppose so, I am also in favor of it being off by default

@Martin521 Martin521 closed this Oct 5, 2023
@Martin521
Copy link
Contributor Author

Closed in favor of #16064

@Martin521 Martin521 deleted the Warn-if-function-shadows-union-case branch October 23, 2023 15:43
Sign up for free to 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.

4 participants