[erlang-questions] code:lib_dir and dialyzer

Nicolas Charpentier nc@REDACTED
Tue Jan 6 07:57:12 CET 2009


Hi,

Running Dialyzer (1.8.3) on my code, I got an error on a call to 
code:lib_dir/1.

Here is the code:lib_dir/1 source:
%% XXX is_list() is for backwards compatibility -- take out in future 
version
-spec lib_dir(App :: atom()) -> string() | {'error', 'bad_name'}.
lib_dir(App) when is_atom(App) ; is_list(App) -> 	call({dir,{lib_dir,App}}).


And here is my test code:
test_lib_dir() ->
	Path = code:lib_dir(kernel),
	Path = code:lib_dir("kernel").

Both calls to code:lib_dir/1 are valid on a runtime system even if the 
clause with the string parameter is kept for backward compatibility

Running Dialyzer on my code, I'm expecting an error like this:
"The call code:lib_dir([101 | 107 | 108 | 110 | 114,...]) breaks the 
contract (atom()) -> string() | {'error', 'bad_name'}".

But I got this one:
"The call code:lib_dir([101 | 107 | 108 | 110 | 114,...]) will never 
return since it differs in argument position 1 from the success typing 
arguments: (atom())"


Is it a dialyzer bug ?


Additional information:
- My PLT is up-to-date and contains the kernel application.
- I'm running dialyzer from the source files.

---
Nicolas Charpentier
http://charpi.net




More information about the erlang-questions mailing list