[erlang-questions] Erlang dialyzer warnings for internal functions.

WW kingwang98@REDACTED
Sun Apr 28 18:41:44 CEST 2019


Sorry for disturbing Frank!
Now the new thread for discussion of dialyzer issues ..........
Hi guys I have moved dialyzer discussions on this thread, so we can continue here! 


Code example 
=======================================================-module(helloworld).
-export([start/0]).
%%-export([validator/1]).

start()->
    try 
        validator(undefined),
        validator([]),
        validator(3)
    catch
          exit:Reason->
              {error, Reason}    
    end.

%%%###=======================================================================###
-spec validator(X::any())->no_return().
%%%###=======================================================================###          
validator([])->
exit({error, "empty list"});            
           
validator(undefined) ->
exit({error, undefined});

validator(_Any)->
exit({error,"unknown"}).

=========================================================================================When function in module validator/1 is not exported, dialyzer gives warnings. Checking whether the PLT /home/eweiwan/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis...
helloworld.erl:18: The pattern [] can never match the type 'undefined'
helloworld.erl:24: The variable _Any can never match since previous clauses completely covered the type 'undefined'
 done in 0m1.45s
done (warnings were emitted)   <<<<<<<<<<<<<<<<<<<<<<<<<<
-------------------------------------------------------------------------------------------------------------------------------------------------
When function is exported, dialyzer result :
  Checking whether the PLT /home/eweiwan/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis... done in 0m1.55s
done (passed successfully)    <<<<<<<<<<<<<<<<<<<<<<<<<<<<
---------------------------------------------------------------------------------------------------------------------------------------------------
What is the best solution to avoid dialyzer warnings meanwhile also satisfy my use cases.?
Thank you 
BR//Wei




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190428/9762b21c/attachment.htm>


More information about the erlang-questions mailing list