E4177#
Extracting bytes sequence using bitstring pattern must be byte-aligned.
Erroneous example#
test {
let a : Array[Byte] = [b'\xFF', b'\x00']
match a {
[u1be(flag), ..rest] => {
inspect(flag, content="1")
inspect(rest.length(), content="1")
}
_ => fail("")
}
}
Suggestion#
Align the bit pattern to full bytes before extracting a byte sequence.
test {
let a : Array[Byte] = [b'\xFF', b'\x00']
match a {
[u8be(value), ..rest] => {
inspect(value, content="255")
inspect(rest.length(), content="1")
}
_ => fail("")
}
}