[erlang-questions] Force TLS v1.2
WW
kingwang98@REDACTED
Sun Apr 28 01:30:02 CEST 2019
The problem is that I have already a internal function call that (any()) case
Best Regards W.W.(KingWang)
On Saturday, April 27, 2019, 10:52:11 PM GMT+2, Hugo Mills <hugo@REDACTED> wrote:
On Sat, Apr 27, 2019 at 08:15:10PM +0000, WW wrote:
> Thank you for your answer Kostis.
> But will erlang crash if any other internal function call this internal function with an argument of integer() or someother term()?
The point here is that dialyzer can *prove* that the function will
not be called with anything other than the first two cases. It
therefore tells you that the third catch-all case is impossible. You
can safely remove that third clause.
If at some point in the future you write some code which could call
the function with some other input, then dialyzer will tell you about
that, too.
If you want a quiet dialyzer, the solution here is to remove the
third (catch-all) clause, until you have some code which actually
needs it.
Hugo.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------- ###=====================================================================###
> -spec convert_result_and_exit(any()) -> no_return().
> %%%
> ###=====================================================================###
> convert_result_and_exit({error, ErrReason}) when is_binary(ErrReason)->
> exit({error, ErrReason}); convert_result_and_exit(no_permission)-> exit(no_permission).
>
> test() -> convert_result_and_exit ( [1,2,3] ). ( It is a use case , why "so they cannot be with any() as argument" ? Where in the erlang doc defined that?)
>
> In this case, test() will crash owing to missing the convert_result_and_exit(_E) -> exit({error, <<"Unknown reason">>}). I do not want it crash, I need a quiet exit (catch it afterwards)instead, will that be possible ?----------------------------------------------------------------------------------------------------------------------------------------------------------------
> The question is : Why dialyzer could not detect the internal non-exported spec ? Or Erlang module interal function should not have any spec at all , because dialyzer doesn't care?
> Is it the limitation of dialyzer or wrong in the design? What is the best solution, in my situation?
> BR//Wei Wang
> Best Regards W.W.(KingWang)
>
> On Saturday, April 27, 2019, 4:52:29 PM GMT+2, Kostis Sagonas <kostis@REDACTED> wrote:
>
> On 4/27/19 12:43 PM, WW wrote:
> > But according to spec the input of the function can be any()! It is
> > obvious the _E should be considered, otherwise erlang will crash.
> >
> > Am I wrong?
>
> Yes, you are.
>
> The function is not exported; all calls to it are from within the module
> (i.e., known to dialyzer), so they cannot be with any() as argument;
> they can only be with the term types that dialyzer has inferred.
>
> Kostis
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
--
Hugo Mills | You can get more with a kind word and a two-by-four
hugo@REDACTED carfax.org.uk | than you can with just a kind word.
http://carfax.org.uk/ |
PGP: E2AB1DE4 | Marcus Cole, Babylon 5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190427/671eb2fd/attachment.htm>
More information about the erlang-questions
mailing list