Str.regexp raises "Invalid_argument: index out of bounds" #7369
Original bug ID: 7369
let x = "if\( \|\t\|\n\|\f\|\t\|\).\( \|\t\|\n\|\f\|\t\|\)=\( \|\t\|\n\|\f\|\t\|\).*";;
val x : string =
Exception: Invalid_argument "index out of bounds".
The backtrace is not very useful, just pointing to recursive invocations of emit_code:
Raised by primitive operation at file "str.ml", line 254, characters 4-49
Comment author: @johnwhitington
I missed the top line. The error is in patch_instr at l254
(* Fill a reserved instruction slot with a GOTO or PUSHBACK instruction *)
from a Group (n, r) call to emit_code at l385
Here are the input values to patch_instr for the whole run:
patch_instr prog length = 32, opc = 16, dest = 11, pos = 8
So it's trying to patch an instruction in the bytecode at position 64 in a bytecode program array 0...63.