Dialyzer and parameterized type for record
Сергей Прохоров
seriy.pr@REDACTED
Tue Jul 28 16:06:06 CEST 2020
I found some oddity in how Dialyzer is not reporting spec violations when I
use a parameterized type that is defined as record. Simple example:
-record(my_record, {my_field, <..>}).
-define(VAL_1, 1).
-define(VAL_2, 2).
-type my_rec(FieldType) :: #my_record{my_field :: FieldType}.
test() ->
takes_subtype1(#my_record{my_field = ?VAL_2}).
-spec takes_subtype1(my_rec(?VAL_1)) -> ok.
takes_subtype1(Rec) ->
gen_server:call(..., Rec).
but it would report similar scenario when I use, eg, tagged tuples:
-type my_rec(FieldType) :: {my_record, FieldType}.
test() ->
takes_subtype1({my_record, ?VAL_2}).
Here is the complete gist with more examples:
https://gist.github.com/seriyps/d4daa42185ba2ce2e319184199cd4039
Can someone explain what kind of "feature" is this? Should it be considered
as a bug in Dialyzer? O I miss something?
Regards,
Sergey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200728/648bfd6a/attachment.htm>
More information about the erlang-questions
mailing list