[erlang-questions] Dialyzer and binary() supertypes
James Aimonetti
james@REDACTED
Mon Aug 27 23:10:42 CEST 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
My assumption is that Dialyzer is letting you know that {binary(),
binary()} is superfluous and can be removed (at least in the example
you provided), and that you can be even more specific with your
binary() declaration.
- -type ne_binary() :: <<_:8,_:_*8>>.
We use the above type to indicate the function does not accept empty
binaries. See if that helps?
On 08/27/2012 02:06 PM, Olav Frengstad wrote:
> Hey,
>
> I have the following snippet of code which I'm trying to get
> Dialyzer to pass:
>
> -module(test).
>
> -compile([export_all]).
>
> -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?
>
> Regards, Olav
>
- --
James Aimonetti
Distributed Systems Engineer / DJ MC_
2600hz | http://2600hz.com
sip:james@REDACTED
tel: 415.886.7905
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iQEcBAEBAgAGBQJQO+JSAAoJENc77s1OYoGg05UIAKs6YrgXUuiL02t1T5Ihj1yo
muu9q69DJsO/0kH+Xi7vcUrSpudeApay6OxCl1RrNR2nsuQA4xtJBZtaEya52wi5
U+gZ/bIptSkG6T3UsNzxlWrNoL21+OGU42KK89R+d/DXOQYJjFC0izZGz1qqIqLs
Mdz6qfTcuPPPMnpUYvxCpwmUEAZe5DyQNvKttQXOQBDx6tH6QNiLE2O3NZ5W+3iU
KIke56oFppGGLsix5Rh8/QZdFEOPxeg5xOMsYujToWINYVLLrnNPHOoJ3joa6KGe
ocoQZJuihY2gCDysA56fXC1yh1ElN5FO8CAB9EFHljAFdiVmSOD+1fv8GVHTO3Q=
=d3gL
-----END PGP SIGNATURE-----
More information about the erlang-questions
mailing list