ocaml

Make the import_graph field immutable (explanation follows) master

This is related to 7ba54ad1da28456aa7d35ab95c011bc95480ae57. The issue that the mentioned commit has fixed is a misunderstanding of the mutable value semantics of OCaml records. A simplified version of this bug is, I think, the following: type t = { foo : string; mutable bar : int} (* will crash on assertion *) let _ = let r1 = { foo = "hello"; bar = 0 } in let r2 = { r1 with foo = "hello world" } in r1.bar <- 2; assert (r2.bar = 2) When you replace a record by doing a functional update, the mutable fields are *new* rather than aliased. To put it another way, the following type `t2` has very different semantics from `t`: type t2 = { foo : string; bar : int ref } Anyway, this kind of thing is pretty subtle in OCaml (in contrast to something like Swift, where mutable fields of let-bound records cannot be mutated). For that reason, I think it's best to remove the mutability entirely.


Author Jon Sterling Date Commit 515c2edf Parent 4dbc86dd Change ID swnmnvmz
+1 -1
1 changed file