Why can't I compile a program with unused variables in Ocaml?
let foo a b = a + b
-- Error (warning 32 [unused-value-declaration]): unused value foo.
Why can't I compile a program with unused variables in Ocaml?
let foo a b = a + b
-- Error (warning 32 [unused-value-declaration]): unused value foo.
Copyright © 2021 Jogjafile Inc.
You can disable the promotion of the warning to an error by customizing the flags in your dune file:
or disabling the promotion with an attribute in the file itself
or for just the value:
(and you can use
-wand@warningfor disabling the warning itself rather than its promotion to an error.)It is also possible to use a leading underscore to indicate the intent that a value is purposefully unused:
Nevertheless, I find this warning generally useful to avoid dead code in the source code and I would not recommend to disable it.