E4177

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  : [] = [b'\xFF', b'\x00']
  match  {
     => {
      (, ="255")
      (.(), ="1")
    }
    _ => ("")
  }
}