I am using Dialyzer to fix errors in Erlang code.
io:format(IoDevice, "[]");
This line produces the following error:
The call io:format(IoDevice::pid(),[91 | 93,...])
will never return since the success typing is
(atom() | binary() | string(),[any()]) -> 'ok'
and the contract is (Format,Data) -> 'ok'
when Format :: format(), Data :: [term()]
I am not able to understand what the problem is can anyone explain it?
Thank you
I recommend to read io manual page. Its usage is simple:
1> io:format("hello ~p~n", [world]). % ~n means newline
hello world
ok
2> io:format("hello ~p~n", [<<"world">>]).
hello <<"world">>
ok
3> io:format("hello ~s~n", [<<"world">>]).
hello world
ok
In above dialyzer told you that io:format/2
(format/2
means function format
which accepts 2 arguments) accepts an atom()
or string()
or binary()
as 1st argument and a list with zero or more elements as 2nd argument. According to your code, dialyzer detects that IoDevice
is an Erlang pid()
not an string()
or binary()
.