[erlang-questions] Dialyzer warning: variable can never match since previous clauses completely covered the type

David Sveningsson <>
Wed Mar 25 13:40:42 CET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, I have an issue with a dialyzer warning, see the test-case below. I
don't know if I'm doing something wrong or not but I cant fix the
warning. Any ideas?


- -module(test).
- -export([start/0]).

- -spec foo() -> ok | {error, reason}.
foo() ->
	case random:uniform(10) of
		N when N > 5 -> ok;
		_ -> {error, foobar}
	end.

start() ->
	{A,B,C} = now(),
	random:seed(A,B,C),
	
	R = case foo() of
		ok ->
			ok;
		Error ->
			Error
	end,
	io:format("R: ~p~n", [R]),
	init:stop(0).



# dialyzer -c test.erl --src
  Checking whether the PLT /Users/ext/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis...
test.erl:18: The variable Error can never match since previous clauses
completely covered the type 'ok'
Unknown functions:
  init:stop/1
 done in 0m0.26s
done (warnings were emitted)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknKJkoACgkQ6pa1H/H5pqXzmQCfRfFxQjY1XwF8xV5RiU6RNHtA
d70An29l0rqiLMQLIaiBt1HSu1O6U5WK
=rWIu
-----END PGP SIGNATURE-----



More information about the erlang-questions mailing list