length as 'foo'. Before we were saving the running offset and length.
This commit also adds a regression test. (Bug found by Matej Kosik).
match bind with
| Some name ->
<:expr<
- let $lid:name$ = ($lid:data$, $lid:off$, $lid:len$) in
+ let $lid:name$ = ($lid:data$,
+ $lid:original_off$, $lid:original_len$) in
$inner$
>>
| None -> inner in
--- /dev/null
+(* Regression test for bug in 'as-binding' found by Matej Kosik.
+ * $Id$
+ *)
+
+open Printf
+open Bitstring
+
+let bits = Bitstring.ones_bitstring 1 in
+bitmatch bits with
+| { _ : 1 } as foo ->
+ let len = Bitstring.bitstring_length foo in
+ if len <> 1 then (
+ hexdump_bitstring stderr foo;
+ eprintf "test error: length = %d, expecting 1\n" len;
+ exit 1
+ )
+| { _ } ->
+ assert false