ResScript v11.0.0-rc.8 Array access Type Errors

v11.0.0-rc.8 complains about the following code. It was working fine in v11.0.0-rc.4.
Does anyone know why?

let numberGrid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
numberGrid[1][1] = 0
Type Errors
[E] Line 2, column 0:
This has type: option<array<int>>
  But this function argument is expecting: array<'a>

playground link (v11.0.0-rc.8)

rc.4 outputs:

// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Caml_array from "./stdlib/caml_array.js";

var numberGrid = [
  [
    1,
    2,
    3
  ],
  [
    4,
    5,
    6
  ],
  [
    7,
    8,
    9
  ]
];

Caml_array.set(Caml_array.get(numberGrid, 1), 1, 0);

export {
  numberGrid ,
}
/*  Not a pure module */

playground link (v11.0.0-rc.4)

Since rc.5 the playground comes with RescriptCore opened by default. Thus array access always returns an option and never throws exceptions.

To get the old behavior back, it comes with an OCamlCompat module. This way it should work with rc.5+ as well:

open! OCamlCompat

let numberGrid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
numberGrid[1][1] = 0
3 Likes