possible bug (?) Options

9 views
Skip to first unread message

Matej Kosik

unread,
Jan 16, 2012, 1:02:15 PM1/16/12
to bitstring
Hello,

I am using bitstring a lot these days.

I have found another surprise today. The following tiny program:

bitmatch (BITSTRING { true : 1 }) with
| { true : 1 } as foo ->
Printf.printf "DEBUG 0: %d\n" (Bitstring.bitstring_length
foo)
| { _ } ->
Printf.printf "DEBUG 1\n";

when compiled and run, prints:

DEBUG 0: 0

Is this expected behavior? I guess the correct output should be:

DEBUG 0: 1

because the matched bitstring has length 1. Right?

Richard W.M. Jones

unread,
Jan 16, 2012, 5:56:16 PM1/16/12
to bits...@googlegroups.com

Yes, this is a bug.

The expanded code correctly gets the length, then subtracts 1 from it,
for reasons I can't quite understand at the moment ...

Rich.

--
Richard Jones
Red Hat

Richard W.M. Jones

unread,
Jan 16, 2012, 6:05:03 PM1/16/12
to bits...@googlegroups.com

Actually that's not the right explanation.

It seems like the 'as' syntax is binding the wrong thing. It takes me
some time to get back "into" bitstring because the syntax extension is
complex. But yes, this is surely a bug.

Richard W.M. Jones

unread,
Jan 17, 2012, 8:02:57 AM1/17/12
to bits...@googlegroups.com
On Mon, Jan 16, 2012 at 10:02:15AM -0800, Matej Kosik wrote:

Please try the following commit which should fix this issue:

https://code.google.com/p/bitstring/source/detail?r=189

Reply all
Reply to author
Forward
0 new messages