7

I'm using lager to do my logging; it has a parser transform which converts lager:warn/1, etc. functions into lager:trace... functions.

dialyzer doesn't process the parser transform, so it warns with Call to missing or unexported function lager:warn/1.

How do I tell it that this function does exist, and not to warn about it?

Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380
  • AFAIK dialyzer inspects beam files, not src (erl), so probably your src files were compiled without parse_transform flag? I use Erlang r16b01, lager 2.0.0 and dialyzer and all work fine. – sysoff Dec 05 '13 at 19:04
  • "Dialyzer starts its analysis from either debug-compiled BEAM bytecode or from Erlang source code." -- http://www.erlang.org/doc/man/dialyzer.html – Roger Lipscombe Dec 06 '13 at 09:58
  • I'm using the dialyzer targets from concrete, https://github.com/opscode/concrete/ – Roger Lipscombe Dec 06 '13 at 09:58
  • I checked concrete. It works fine. Are you sure you added `-compile([{parse_transform, lager_transform}]).`? – sysoff Dec 10 '13 at 05:54
  • It's in `erl_opts` in `apps/Foo/rebar.config`. – Roger Lipscombe Dec 10 '13 at 08:42
  • I was just having the same problem. No clue how to avoid the warnings however when I had dialyzer look at my beam files (compiled with debug_info and the lager transform applied) it did not complain. When running dialyzer on the erl files it warned about these of course. – Khorkrak Jan 29 '14 at 02:48

2 Answers2

3

The best way to do it is to have dialyzer look at your compile beam files, as long as the parse transform is applied when the code is compiled and you include lager in your .plt file it will be fine

Zachary K
  • 3,205
  • 1
  • 29
  • 36
1

Stumbled upon a way by checking out what's done in the meck project's Makefile regarding dialyzer. Have a look: Makefile
Key part is this:

| \
    fgrep -v -f ./dialyzer.ignore-warnings

So within that file: dialyzer.ignore-warnings you'll see what to do. In my version I added:

Call to missing or unexported function lager:warning/1
Call to missing or unexported function lager:warning/2
Call to missing or unexported function lager:info/1
Call to missing or unexported function lager:info/2
Call to missing or unexported function lager:error/1
Call to missing or unexported function lager:error/2

And the warnings I was getting went away. I do of course have this entry in my rebar.config:

{erl_opts, [{parse_transform, lager_transform}]}. 
legoscia
  • 39,593
  • 22
  • 116
  • 167
Khorkrak
  • 3,911
  • 2
  • 27
  • 37
  • 2
    the only problem with this "solution" is that the exit code is still 2, even if there are no other warnings – grahamrhay Jan 17 '15 at 16:51