Yes, your problem arises from the fact that you are testing for javascript toplevel.
When you use standard ocaml toplevel, operation +. works with OCaml floats, i.e. with a double block inside a block, two parameters are expected +. will be pointers to such fields. In your example, instead of a pointer, you specify an integer OCaml 2 (internally it is represented as 5, i.e. 2 <1 + 1), so OCaml segfaults when trying to read a double, which should be in position 0x5 in memory ...
In the js_of_ocaml browser js_of_ocaml floats are just javascript floats, and integers are javascript integers, and +. is a javascript add-on that can add integers and float (by automatically converting integers to float), since the values ββare marked with their types.
source share