[erlang-questions] Temporarily violating record type constraints annoys dialyzer

Roger Lipscombe roger@REDACTED
Mon Nov 12 11:58:36 CET 2018

I've got a record defined as follows (e.g., and very simplified):

-record widget {
    id :: binary(),
    name :: binary(),
    size :: integer()

I parse that from (e.g.) a proplist:

parse_widget(Props) ->
    parse_widget(Props, #widget{}).

parse_widget([{name, Name} | Rest], Acc) ->
    parse_widget(Rest, Acc#widget { name = Name });
% etc.

Dialyzer isn't happy that my fields are initially set to 'undefined',
even though this only occurs during the parsing step, and isn't a big

What can I do to deal with this? Either re-structuring my code or
persuading dialyzer that it's OK would both be acceptable.

More information about the erlang-questions mailing list