[erlang-questions] Type specs depending on build-time selected code
Fri Nov 18 20:21:04 CET 2011
On 11/18/11 16:56, Olivier BOUDEVILLE wrote:
> I suppose there are situations where the actual code for a function is
> based on preprocessor defines while we want the type specs to encompass
> all possible implementations.
> A simple example could be a debug mode which is to be enabled/disabled
> at build time:
> ... LOTS OF STUFF DELETED ...
> Dialyzer is right when telling that "is_debug_mode_enabled/0 states that
> the function might also return 'false' but the inferred return is
> 'true'" (when the symbol debug_mode_is_enabled is defined) , but I would
> like to be able to suppress this warning as the same code built with a
> different preprocessor flag should offer the same API/type spec to the
> user code.
> ... MORE STUFF DELETED ...
> Am I missing something? Is there a way to tell Dialyzer to ignore *for
> this particular function* the "underspecification"?
We satisfy your users even before they ask requests!
What you are describing is already present in the 'master' branch of the
upcoming R15 release of Erlang (you can get it now if you want) and
these warnings are now suppressed by default. They will be printed only
if you explicitly use -Wunderspecs.
More information about the erlang-questions