erlang - Understanding dialyzer result -
i have following function:
-spec check_connection_header(list()) -> atom(). check_connection_header([{<<"connection">>, <<"close">>}|_]) -> close; check_connection_header([{<<"connection">>, <<"close">>}|_]) -> close; check_connection_header([{<<"connection">>, <<"close">>}|_]) -> close; check_connection_header([{<<"connection">>, <<"close">>}|_]) -> close; check_connection_header([_|rest]) -> check_connection_header(rest); check_connection_header([])-> keep_alive.
and when run dialyzer following output:
131: pattern [{<<67:8/integer-unit:1,111:8/integer-unit:1,110:8/integer-unit:1,110:8/integer-unit:1,101:8/integer-unit:1,99:8/integer-unit:1,116:8/integer-unit:1,105:8/integer-unit:1,111:8/integer-unit:1,110:8/integer-unit:1>>, <<99:8/integer-unit:1,108:8/integer-unit:1,111:8/integer-unit:1,115:8/integer-unit:1,101:8/integer-unit:1>>} | _] can never match type [] 134: pattern [{<<67:8/integer-unit:1,111:8/integer-unit:1,110:8/integer-unit:1,110:8/integer-unit:1,101:8/integer-unit:1,99:8/integer-unit:1,116:8/integer-unit:1,105:8/integer-unit:1,111:8/integer-unit:1,110:8/integer-unit:1>>, <<67:8/integer-unit:1,108:8/integer-unit:1,111:8/integer-unit:1,115:8/integer-unit:1,101:8/integer-unit:1>>} | _] can never match type [] 137: pattern [{<<99:8/integer-unit:1,111:8/integer-unit:1,110:8/integer-unit:1,110:8/integer-unit:1,101:8/integer-unit:1,99:8/integer-unit:1,116:8/integer-unit:1,105:8/integer-unit:1,111:8/integer-unit:1,110:8/integer-unit:1>>, <<99:8/integer-unit:1,108:8/integer-unit:1,111:8/integer-unit:1,115:8/integer-unit:1,101:8/integer-unit:1>>} | _] can never match type [] 140: pattern [{<<99:8/integer-unit:1,111:8/integer-unit:1,110:8/integer-unit:1,110:8/integer-unit:1,101:8/integer-unit:1,99:8/integer-unit:1,116:8/integer-unit:1,105:8/integer-unit:1,111:8/integer-unit:1,110:8/integer-unit:1>>, <<67:8/integer-unit:1,108:8/integer-unit:1,111:8/integer-unit:1,115:8/integer-unit:1,101:8/integer-unit:1>>} | _] can never match type [] 143: pattern [_ | rest] can never match type []
i pretty new dialyzer , have trouble interpreting output of dialyzer. understand saying first 5 clauses of function can't match [], deliberate part since i'm matching empty list in sixth clause.
my erlang version erlang/otp 19.0 , dialyzer version v3.0.
a interesting discover dialyzer does'nt complain above code when run dialyzer v2.8 , erlang/otp 18 on machine.
things i've tried far:
i'm not experienced binaries in erlang initial thought had misunderstood binary pattern matching, seems not case. function passes test cases (calling function [] parameter no problem), , if replace binaries normal strings in function heads same complaints dialyzer.
rebuilt plt , cleaned project
thanks in advance
the reason dialyzer warnings function called [] due defect in code.
so conclude: dialyzer not wrong time either :)
Comments
Post a Comment