[erlang-questions] Dialyzer and record MatchSpec warnings

Maxim Treskin <>
Tue Feb 3 06:32:01 CET 2009


I found incomprehensible thing in dialyzer's output for MatchSpec using

This is my module:
-export([get_ctrl_good/1, get_ctrl_bad/1]).

-record(controller, {
          id :: integer(),
          address :: any(),
          type :: any(),
          name :: string(),
          profile :: integer()

get_ctrl_good(CtrlId) ->
    CtrlMS = [{#controller{id = CtrlId, _='_'}, [], ['$_']}],
    case mnesia:dirty_select(controller, CtrlMS) of
        [Controller] -> [Controller];
        _ -> not_found

get_ctrl_bad(CtrlId) ->
    CtrlMS = [{#controller{id = CtrlId}, [], ['$_']}],
    case mnesia:dirty_select(controller, CtrlMS) of
        [Controller] -> [Controller];
        _ -> not_found

So, when I make dialyzer --src -c loc.erl, I see following output:

  Checking whether the PLT /home/zert/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis...
loc.erl:13: Function get_ctrl_good/1 has no local return
loc.erl:14: Record construction
violates the declared type for #controller{}
 done in 0m0.59s
done (warnings were emitted)

get_ctrl_bad/1 not contains _='_' in MatchSpec for dirty_select query and
does not work due to unassignet fileds of record became to undefined value.
get_ctrl_good/1 works fine, but dialyzer not think so.
BTW, I know about ets:ms2fun, it gave me same results as in get_ctrl_good/1

My OTP release is R12B-5.

How I can make this code right?

Thank you

Maxim Treskin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090203/297fb981/attachment.html>

More information about the erlang-questions mailing list