現在編集中です。
ソースコード
error_sample.erl
-module(error_sample).
%%----------------------------------------------------------------------------------------------------------------------
%% Exported API
%%----------------------------------------------------------------------------------------------------------------------
-export([
h/1
]).
%%----------------------------------------------------------------------------------------------------------------------
%% Macros & Records & Types
%%----------------------------------------------------------------------------------------------------------------------
-record(r, {
item :: term()
}).
-record(s, {
item1 :: term(),
item2 :: term()
}).
-type r_list() :: [#r{}].
-type s_list() :: [#s{}].
%%----------------------------------------------------------------------------------------------------------------------
%% Exported Functions
%%----------------------------------------------------------------------------------------------------------------------
-spec h([term()]) -> ok.
h(List) ->
{_, F} = f(List),
g(F).
%%----------------------------------------------------------------------------------------------------------------------
%% Internal Function
%%----------------------------------------------------------------------------------------------------------------------
-spec f([term()]) -> {[1], r_list()}. % XXX: r_list() がおかしい
f(List) ->
f(List, {[], []}).
-spec f([term()], {[1], s_list()}) -> {[1], s_list()}.
f([], R) ->
R;
f([H|T], {R1, R2}) ->
f(T, {[1|R1], [#s{item1=H}|R2]}).
-spec g(s_list()) -> ok.
g([]) ->
ok;
g([H|T]) -> % error_sample.erl:xx: The pattern [H | T] can never match the type []
io:format("~p", [H#s.item1]),
g(T).
エラー
$ dialyzer ...
error_sample.erl:xx: The pattern [H | T] can never match the type []