[erlang-patches] Add spec for base64:encode_binary/1
Wed Aug 18 14:57:34 CEST 2010
On Wed, Aug 18, 2010 at 12:26 PM, Kostis Sagonas <> wrote:
> Paul Oliver wrote:
>> Dialyzer was reporting that use of base64:encode(Foo :: binary()) had spec
>> binary() -> <<_:_*1>>. The binary comprehension in base64:encode seems to
>> result in the return type of <<_:_*1>>. The patch below enforces a return
>> type of binary().
> Sorry, but I cannot understand your mail... Can you elaborate a bit?
> First of all, dialyzer cannot be reporting what you are claiming because
> the spec of base64:encode/1 is:
> -spec encode(string() | binary()) -> binary().
> You are probably referring to some other function...
> Looking at your patch, it seems that it refers to base64:encode_binary/1
> which is a *module-local* function, not an exported one. Why do you feel the
> need to add a spec to this function? What exactly is it that changes in your
> use case?
Sorry for the bother and disregard this patch. I had code like:
-spec(check_hmac(Bin :: binary()) -> binary()).
and looking now, it seems that the version of R14 I had compiled with had:
-spec sha_mac(iodata(), iodata()) ->* binary*.
-spec sha_mac_96(iodata(), iodata()) -> binary.
sha_mac(Key, Data) ->
sha_mac_96(Key, Data) ->
which was fixed here
I had applied my "fix" to the dev branch, saw dialyzer now passed my code
and assumed I had fixed the problem.
More information about the erlang-patches