Please, don't do that hack ! The compiler assumes immutable data are not
mutated and optimise knowing that.
My understanding was that it is unsafe to Obj.magic an immutable data structure into a mutable one (one mental model is that immutable data might be allocated in read-only memory, although that's not what the current implementation does), but that on the contrary it is safe to Obj.magic a mutable data-structure into an immutable one. The Obj.magic-using code for List.map, implemented in Extlib and inherited by Batteries, is careful to use an unsafe cast in exactly the second situation. This is a feature that other languages (eg. Mezzo) safely provide.
If this last technique became invalid because of compiler optimization in the future, that would need to be clearly exposed and justified. Could you confirm that this is not the case today?
(I think this is also the way immutable recursive value work, with a tying-the-knot mutation followed by a conceptual "freeze" of the resulting structure.)