Discrepency in partial function element modifiction between 4.05/4.06

The following simplified example returns 1,2,3 in 4.05 and 0,0,0 in 4.06. I cannot find anything in the 4.06{.1} release notes the explain this change in behaviour

type t =
  {
    mutable i : int;
  }

let foo ({ i; } as flt) x =
  flt.i <- i + 1;  # in 4.05 this update persists out of scope
  i

let _ =
  let bar =
    let bar_ = { i = 0 } in
    foo bar_ in
  for i = 1 to 3 do
    Printf.printf "Output: %d\n" (bar i)
  done

We have come up with multiple workarounds using ref and/or classes, but would like to understand why. Thanks in advance!

You don’t have to use ref or class. Not extracting the value of the field i in the definition of foo is enough:

let foo flt x =
  let i = flt.i in
  flt.i <- i + 1; 
  i

This is indeed bug that has been fixed in 4.06.0: See https://github.com/ocaml/ocaml/pull/1308 for more discussion.