<div dir="ltr"><div><div>Dialyzer checks the type of record elements when creating them
 but not when updating them. Pasted below is a minimal working example.<br></div><br></div>Nicolas<br><div><div><div><br><br><br><br>-module(test).<br><br>-export([ baz/1, quux/2 ]).<br><br>-type bar()    :: atom().<br>-type notbar() :: string().<br><br>-record(foo, { bar :: bar() }).<br><br><br>% CORRECT: Dialyzer generates a warning<br>% test.erl:13: Invalid type specification for function test:baz/1. The success typing is (atom()) -> #foo{bar::atom()}<br>-spec baz(notbar()) -> #foo{}.<br><br>baz(NotBar) -><br>  #foo{ bar = NotBar }.<br><br>% INCORECT: Dialyzer does not say anything<br>-spec quux(#foo{}, notbar()) -> #foo{}.<br><br>quux(Foo, NotBar) -><br>  Foo#foo{ bar = NotBar }.</div></div></div></div>