Error on declaring a bitstring type

66 views
Skip to first unread message

Iuri Machado

unread,
Apr 18, 2016, 12:32:15 PM4/18/16
to elixir-lang-core
Hi everyone, I'm trying to do this:

@type client_login_message :: <<_::size(8),
                                _
::unsigned-little-integer-size(16),
                                _
::unsigned-little-integer-size(32),
                                _
::size(8),
                                _
::size(8),
                                _
::size(8),
                                _
::unsigned-little-integer-size(16),
                                _
::unsigned-little-integer-size(32),
                                _
::unsigned-little-integer-size(32),
                                _
::unsigned-little-integer-size(32),
                                _
::unsigned-little-integer-size(32),
                                _
::unsigned-little-integer-size(32),
                                _
::size(8),
                                _
::byte>>

But I'm receiving an error while compiling:

== Compilation error on file lib/realm/messages/logon_challenge.ex ==
** (CompileError) lib/realm/messages/logon_challenge.ex:32: type '<<>>'(_) undefined
   
(stdlib) lists.erl:1337: :lists.foreach/2
   
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6


Any ideas?

José Valim

unread,
Apr 18, 2016, 12:35:39 PM4/18/16
to elixir-l...@googlegroups.com
The typespec for bitstrings is limited to only the size and unit:


It seems you want: <<_::8>> (or simply binary()).



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1254c1bb-8276-4c23-9bfa-b96f8412ef5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Iuri Machado

unread,
Apr 18, 2016, 12:40:56 PM4/18/16
to elixir-lang-core, jose....@plataformatec.com.br
Thanks Valim!

Just a little following, is there a reason for this limitation?

José Valim

unread,
Apr 18, 2016, 12:54:39 PM4/18/16
to Iuri Machado, elixir-lang-core
I am actually not sure. The typespecs mechanism simply delegates to Erlang and Dialyzer. I suppose it is because that's the maximum amount of information that the Dialyzer can use from the bitstrings typespecs.



José Valim
Skype: jv.ptec
Founder and Director of R&D

Reply all
Reply to author
Forward
0 new messages