possible bug (?)

14 views
Skip to first unread message

Matej Košík

unread,
Mar 6, 2012, 1:20:28 PM3/6/12
to bitstring
Hello,

Bitstring is a non-trivial syntactic extension so maybe I've got
something wrong.

The compiler accepts this code without any complaints:

(bitmatch Bitstring.empty_bitstring with
{ x : 64 } -> ()
);

Which is what is expected.

---

The compiler rejects this code:

(bitmatch Bitstring.empty_bitstring with
{ x : 65 } -> ()
);

and the reason is explained in the documentation.

---

The curious case is, that the compiler accepts the following case:

let foo = 0 in
(bitmatch some_bitstring with
{ x : foo+65 } -> ()
);

and that does not makes sense with respect to the above examples,
documentation.

The type of variable "x" will be set to "int64" which means that one of
the two undesirable things can happen:
- either 65-bits are taken but only first/last 64-bits are bound in "x"
while the remaining bit(s) are dropped
- or 64-bits are taken where programmer expected some other number of
bits to be taken.

I would like to ask if I have misunderstood something.

Thanks in advance.

Reply all
Reply to author
Forward
0 new messages