I think there is an error in the description of pattern matching binaries. The section Binaries and Pattern Matching seems to say that all types are treated as bitstrings. The binary type seems to be different. It is expecting the size in bytes, rather than bits. I have a pattern like:
<< _::size(extlen), key::[binary, size(keylen)], data::binary >> = tail
extlen is bits, but keylen is bytes, not bits.