[erlang-questions] Dialyzer and binary() supertypes

Olav Frengstad <>
Mon Aug 27 23:06:54 CEST 2012


I have the following snippet of code which I'm trying to get Dialyzer to pass:



-spec a({binary(), binary()} | binary()) -> atom().
a(<<"abc/def">>) -> ok1.
a(<<"hijk/lmno">>) -> ok2.

When running the above I get an error regarding the type specification:
[/tmp] erlc +debug_info test.erl && dialyzer test.beam -Wunderspecs
test.erl:7: Invalid type specification for function test:a/1. The
success typing is (<<_:56,_:_*16>>) -> 'ok1' | 'ok2'

Am I expected to create a custom type for to match static binary
patterns, or is there some other type I can use for binaries with
length() > 0?

Med Vennlig Hilsen
Olav Frengstad

Systemutvikler // FWT
+47 920 42 090

More information about the erlang-questions mailing list