我正在使用 Dialyzer 修复 Erlang 代码中的错误。
io:format(IoDevice, "[]");
Run Code Online (Sandbox Code Playgroud)
此行产生以下错误:
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()]
Run Code Online (Sandbox Code Playgroud)
我无法理解问题出在哪里有人可以解释一下吗?
谢谢
我建议阅读io 手册页。它的用法很简单:
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
Run Code Online (Sandbox Code Playgroud)
在上面的dialyzer 中告诉您io:format/2(format/2表示format接受2 个参数的函数)接受一个atom()或string()或binary()作为第一个参数和一个具有零个或多个元素的列表作为第二个参数。根据您的代码,dialyzer 检测到的IoDevice是 Erlangpid()而不是string()or binary()。
| 归档时间: |
|
| 查看次数: |
137 次 |
| 最近记录: |