Closed Arm-Mike closed 1 year ago
@Arm-Mike : Good catch, thanks for the report!
Maybe it is a bit silly by Ocaml to not truncate negative quantities passed to String.make
. They seem to be obsessed with not a bounds check too much, living by the motto let it crash.
Anyway, I fixed this along the lines you suggested, and the fix should be on master
soon. Is this fine with you or do you need a release of this fix urgently?
As a workaround, you can always patch the output of BNFC with the patch
commandline tool.
The follow type of rule causes the ocaml printer to crash
test. A ::= "{{" Id "}" "}" ; -- Note: should be "}}"
The error message is
Fatal error: exception Invalid_argument("Bytes.create")
I have traced this to the indent function
let indent (i: int) : string = "\n" ^ String.make i ' '
and I think that changed tolet indent (i: int) : string = if i > 0 then "\n" ^ String.make i ' ' else "\n" ;;
to match the behavior of other backends.