[erlang-questions] Bad warning when using short-circuit boolean expressions
Anthony Molinaro
nym-erlang-q@REDACTED
Fri Mar 13 19:36:43 CET 2009
Hi,
I have this code
-module (is_dict).
-include_lib ("eunit/include/eunit.hrl").
-define (is_dict (D), is_tuple (D) andalso element (1, D) =:= dict).
is_dict_test () ->
?assertEqual (false, ?is_dict (a)),
?assertEqual (false, ?is_dict ({a, b})),
?assertEqual (false, ?is_dict ([{a, b}])),
?assertEqual (true, ?is_dict (dict:new())),
?assertEqual (true, ?is_dict (dict:from_list ([{a, b}]))).
which gives
Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [kernel-poll:false]
Eshell V5.6.5 (abort with ^G)
1> c (is_dict).
./is_dict.erl:8: Warning: this expression will fail with a 'badarg' exception
./is_dict.erl:10: Warning: this expression will fail with a 'badarg' exception
{ok,is_dict}
2> is_dict:test ().
Test successful.
ok
3>
The warnings seem wrong as the expression does not fail (or maybe I'm just
doing something wrong with this test?).
-Anthony
--
------------------------------------------------------------------------
Anthony Molinaro <nym@REDACTED>
More information about the erlang-questions
mailing list