Why no warning for unused let bindings?

For those of us that don't have Visual Studio and edit the fsproj by hand, the way to implement Tomas's answer is

<PropertyGroup>
    <OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

As an example, see the project file of FSharp.Core itself.


You can enable warning for unused bindings via the warnon compiler option. If you want to be strict, you can even use warnaserror+ to turn it into an error.

The warning number is 1182 and it is turned off by default as documented in the compiler options page in the F# documentation.

fsc --warnaserror+:1182 --warnon:1182 Program.fs

How to do this will depend on your editor. In Visual Studio, you can do this by specifying "Other flags" and "Treat warnings as errors" in project properties.

Tags:

F#