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

[WIP]Turn unused value warnings on by default #10546

Closed
wants to merge 15 commits into from

Conversation

cartermp
Copy link
Contributor

Based on comment from #10457

Also worth noting that a lot of F# developers turn this one on explicitly

@cartermp cartermp force-pushed the unused-warnings-on-default branch from 58c33f3 to 96ec5c5 Compare November 26, 2020 05:07
@cartermp cartermp closed this Nov 26, 2020
@cartermp cartermp reopened this Nov 26, 2020
@cartermp

This comment has been minimized.

@cartermp cartermp changed the title Turn unused value warnings on by default [WIP] Turn unused value warnings on by default Dec 7, 2020
@cartermp cartermp force-pushed the unused-warnings-on-default branch from 96ec5c5 to ae20dc2 Compare January 5, 2021 19:50
@cartermp cartermp changed the title [WIP] Turn unused value warnings on by default Turn unused value warnings on by default Jan 5, 2021
@cartermp
Copy link
Contributor Author

cartermp commented Jan 5, 2021

Huh. So like, does NoWarn just like, not work?

@cartermp cartermp force-pushed the unused-warnings-on-default branch from 96a6a05 to b7e0494 Compare March 17, 2021 02:48
@KevinRansom KevinRansom reopened this Mar 19, 2021
@KevinRansom KevinRansom changed the title Turn unused value warnings on by default [WIP]Turn unused value warnings on by default Mar 19, 2021
@KevinRansom KevinRansom requested a review from vzarytovskii June 28, 2021 18:13
@vzarytovskii
Copy link
Member

vzarytovskii commented Aug 4, 2021

@cartermp

The issue is that NoWarn has no effect when the warning is in WarningsAsErrors - when we use NoWarn, we add the warning to the tcConfigB.errorSeverityOptions.WarnOff, and then we process WarningsAsErrors, we add the same warning to tcConfigB.errorSeverityOptions.WarnAsError, and this is how we check whether we want to produce a warning.

let ReportWarningAsError options err =
    warningOn err options.WarnLevel options.WarnOn &&
    not (List.contains (GetDiagnosticNumber err) options.WarnAsWarn) &&
    ((options.GlobalWarnAsError && not (List.contains (GetDiagnosticNumber err) options.WarnOff)) ||
     List.contains (GetDiagnosticNumber err) options.WarnAsError)

Which, in our case evaluates to

<doesnt really matter what left evaluates to> || true // Since 1182 is in WarnAsError by default via the FSharpBuild.Directory.build.props

I've removed 1182 from WarningsAsErrors, since it's enabled by default now, and we treat all warnings as errors. Let me know if there are any objections.

CC @KevinRansom @brettfo

@vzarytovskii
Copy link
Member

Some tests are failing, need to add some NoWarns to generated fsprojs (or fix unused vars).

@dsyme
Copy link
Contributor

dsyme commented Aug 6, 2021

@vzarytovskii Let's discuss this

  • 1182 should not be on for F# scripts. It's too intrusive. So this would need to be adjusted for that

  • However if we want it on by default I think a simpler option is to make it on in the default templates for new projects? So much less intrusive, and then the user has control.

  • If we changed it in the compiler I think it should be protected by a langversion switch - the very many changes to tests in this PR indicates how intrusive it is in the language

  • I think we'd need to improve our error message to mention "you can add _ if you want to suppress this"

@vzarytovskii
Copy link
Member

vzarytovskii commented Aug 6, 2021

@vzarytovskii Let's discuss this

  • 1182 should not be on for F# scripts. It's too intrusive. So this would need to be adjusted for that
  • However if we want it on by default I think a simpler option is to make it on in the default templates for new projects? So much less intrusive, and then the user has control.
  • If we changed it in the compiler I think it should be protected by a langversion switch - the very many changes to tests in this PR indicates how intrusive it is in the language
  • I think we'd need to improve our error message to mention "you can add _ if you want to suppress this"

Yeah, the more tests I "fix", the more I think it may be not what we want to enforce via the compiler.

@dsyme
Copy link
Contributor

dsyme commented Aug 6, 2021

Yeah, the more tests I "fix", the more I think it may be not what we want to enforce via the compiler.

Right. I mean I think it's ok for fresh project code.

@vzarytovskii
Copy link
Member

Yeah, the more tests I "fix", the more I think it may be not what we want to enforce via the compiler.

Right. I mean I think it's ok for fresh project code.

Yeah, we can enable it in the templates by default, I guess.

@vzarytovskii vzarytovskii marked this pull request as draft September 6, 2022 17:28
@cartermp
Copy link
Contributor Author

I'll just close this out since it was so long ago

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