I have a module where the -doc attribute is a binary/utf8 string.
When compiled to abstract form and then back to erlang with erl_pp:form/1 it is printed as an binary integer list and not as a string.
If I use a “simple” string it works fine.
-module(test).
-moduledoc("This is a module documentation").
-export([test0/0, test1/0]).
-doc(<<"Just return the integer 10"/utf8>>).
-spec test0() -> integer().
test0() ->
10.
-doc("Just return the integer 10").
test1() ->
10.
Converting forth and back:
2> {ok,[], Term} = compile:file(test,[binary, to_abstr, debug_info]),
Bin = term_to_binary(Term),
%% file:write_file("test.abstr", Bin),
PrettyModule = lists:map(fun(A) -> erl_pp:form(A) end, binary_to_term(Bin)),
io:format("~ts~n", [PrettyModule]).
-file("test.erl", 1).
-module(test).
-moduledoc("This is a module documentation").
-export([test0/0,test1/0]).
-doc(<<74,117,115,116,32,114,101,116,117,114,110,32,116,
104,101,32,105,110,116,101,103,101,114,32,49,48>>).
-spec test0() -> integer().
test0() ->
10.
-doc("Just return the integer 10").
test1() ->
10.
Is this the expected output or would it be possible to print the binary as a string?