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!