rec2json icon indicating copy to clipboard operation
rec2json copied to clipboard

types do not resolve to simplest type

Open stephb9959 opened this issue 5 years ago • 1 comments

Hi,

If I define a record like this:

-record( thing , 
{
 prop1 :: binary() ,
prop2 :: mylist()
}).

And in an include file I have defined

-type mylist :: [ integer() ].

-export_type ([mylist/0]).

I am finding that rec2json does not reduce mylist() to [integer()] and therefore never processes prop2.

Am I missing something or is this intended behaviour or should the be filed as an enhancement?

Thanks

stephb9959 avatar Aug 22 '19 17:08 stephb9959

The short answer is an enhancement should be filed to support local user-defined type. Changing the property to prop2 :: ?MODULE:mylist() and exporting a mylist/1 function will work as well.

rec2json does not inspect the shape of user-defined types, nor does it support local user types. When it comes across prop2 :: my list() it will skip over it completely as it is a localy defined type. For remote types rec2json will attempt to used a function with the same module and name to encode/decode the value.

lordnull avatar Aug 24 '19 17:08 lordnull