OCamlPro / typerex-lint

Tools to manipulate source files (linting, patching, etc.)
Other
22 stars 13 forks source link

Detect execution order traps #159

Open lefessan opened 6 years ago

lefessan commented 6 years ago

It would be nice to catch this:

let f l =
   let acc = ref 0 in
   let rec g l =
     match l with
     | [] -> ()
     | a::r ->
       acc := !acc + a;
       g r
   in
   g l, !acc

g has a side effect on acc, but the result depends on the execution order in tuples.

iguerNL commented 6 years ago

And a variant of this is:

let f l =
   let acc = ref 0 in
   let rec g l =
     match l with
     | [] -> ()
     | a::r ->
       acc := !acc + a;
       g r
   in
   let res = g l, !acc in
   res