Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# Suppress Warnings

Tags:

f#

Sometimes I get annoying pattern matching and indent warnings when compiling F#. Is there a way to disable warnings? I'm pretty OCD over warnings.

like image 789
Ming-Tang Avatar asked Sep 18 '10 05:09

Ming-Tang


1 Answers

In case you forget, you can type

let rec x = lazy(x.Value)

and get the warning

This and other recursive references to the object(s) being defined will be checked for initialization-soundness at runtime through the use of a delayed reference. This is because you are defining one or more recursive objects, rather than recursive functions. This warning may be suppressed by using '#nowarn "40"' or '--nowarn:40'.

which shows that you can use either the compiler flag --nowarn on the command-line, or use the hash-directive #nowarn in your code. The warning number for each warning will be part of the build output (the Visual Studio error list does not display the numbers, so if in VS, build and then inspect the build output). Also, if inside VS, you can go to the project properties page, "Build" tab, and use the "warning level" selector and "suppress warnings" field (a semicolon-delimited list of numbers) to control which warnings are diplayed via the VS UI.

(BTW, I believe #nowarn only turns off the warning in the current file, whereas --nowarn turns it off for the entire project being compiled.)

like image 117
Brian Avatar answered Sep 29 '22 14:09

Brian