eproxus / meck

A mocking library for Erlang
http://eproxus.github.io/meck
Apache License 2.0
811 stars 231 forks source link

dialyzer warnings with meck (73c0b3e) #58

Closed norton closed 12 years ago

norton commented 12 years ago

I noticed a few new dialyzer warnings.

[meck ((73c0b3e...))]$ dialyzer --version Dialyzer version v2.5

[meck ((73c0b3e...))]$ dialyzer --plt ~/.dialyzer_plt.R15B -Wunmatched_returns --src src Checking whether the PLT /Users/norton/.dialyzer_plt.R15B is up-to-date... yes Proceeding with analysis... meck.erl:356: Expression produces a value of type binary(), but this value is unmatched meck.erl:521: Expression produces a value of type binary(), but this value is unmatched meck.erl:653: The pattern <Mod, Func, Args, [Meck = {'meck', 'exec', Arity} | Stack]> can never match the type <atom(),,_,[{atom(),atom(),[any()] | byte(),[any()]},...]> meck_cover.erl:29: Expression produces a value of type 'ok' | binary(), but this value is unmatched meck_cover.erl:30: Call to missing or unexported function cover:compile_beam/2 meck_cover.erl:93: Expression produces a value of type 'ok' | {'error',atom()}, but this value is unmatched meck_cover.erl:97: Call to missing or unexported function cover:get_term/1 meck_cover.erl:104: Expression produces a value of type [any()], but this value is unmatched meck_cover.erl:108: Call to missing or unexported function cover:write/2 done in 0m15.09s done (warnings were emitted)

[meck ((73c0b3e...))]$ git log -n 1 commit 73c0b3e8faaf29677e0fc9b7e64eab27df85d497 Merge: 0e1b928 e84d4d0 Author: Adam Lindberg eproxus@gmail.com Date: Fri Mar 9 17:00:14 2012 -0800

Merge pull request #57 from Erkan-Yilmaz/master

Remove repetition and typo in documentation
eproxus commented 12 years ago

Perfect bug report! The following warnings must remain for now. For R14 compatibility:

meck.erl:653: The pattern <Mod, Func, Args, [Meck = {'meck', 'exec', _Arity} | Stack]> can never match the type 
<atom(),_,_,[{atom(),atom(),[any()] | byte(),[any()]},...]>

These functions are exported by a hack in the code:

meck_cover.erl:30: Call to missing or unexported function cover:compile_beam/2
meck_cover.erl:98: Call to missing or unexported function cover:get_term/1
meck_cover.erl:109: Call to missing or unexported function cover:write/2
norton commented 12 years ago

Thanks!

One suggestion for the warnings that must remain for now.

If it is practical and strait-forward to use a conditional define to enable and to disable certain blocks of code in meck, rebar supports defines based on the platform version. Sorry, I haven't checked the source code of meck.erl:653.

Here is one sample for old_inets:

https://github.com/norton/ubf-jsonrpc/blob/master/rebar.config#L15