Dialyzer does not check record update types

Nicolas Dudebout <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <CA+TMmKmBVhDsHTykNSQr0VZTOiuuMu1N45xGGVVZRFpg3jUqrQ@mail.gmail.com>
Dialyzer checks the type of record elements when creating them but not when
updating them. Pasted below is a minimal working example.

Nicolas




-module(test).

-export([ baz/1, quux/2 ]).

-type bar()    :: atom().
-type notbar() :: string().

-record(foo, { bar :: bar() }).


% CORRECT: Dialyzer generates a warning
% test.erl:13: Invalid type specification for function test:baz/1. The
success typing is (atom()) -> #foo{bar::atom()}
-spec baz(notbar()) -> #foo{}.

baz(NotBar) ->
  #foo{ bar = NotBar }.

% INCORECT: Dialyzer does not say anything
-spec quux(#foo{}, notbar()) -> #foo{}.

quux(Foo, NotBar) ->
  Foo#foo{ bar = NotBar }.

_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.