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 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 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?

@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
@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

@cartermp cartermp closed this Sep 17, 2022
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.

None yet

4 participants