From 2a9abcc03b4e4d4f0bbfcdf681c974a09490e935 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 10 Sep 2026 22:21:13 +0200 Subject: [PATCH 1/9] Update CHANGES with the latest, missed ones --- CHANGES.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bf53af8..cb658ff 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,10 @@ Next release ------------ -- Use dune.3.18 support to generate `x-maintenance-intent` entry -- Patch `ppx_yojson_conv` dependency which was missing a `v`-prefix +- Adjust test suite to be compatible with >= dune.3.22.0 #48 +- Switch to using `ppx_deriving_yojson` instead of `ppx_yojson_conv` #47 +- Use dune.3.18 support to generate `x-maintenance-intent` entry #45 +- Patch `ppx_yojson_conv` dependency which was missing a `v`-prefix #43 - Introduce a `mutaml.opam.template` to avoid opam linting failure #41 - Adjust RE to support `runtest` on OpenBSD too #40 - Remove `which` and `conf-which` dependency #39 From ed89bf09d183566cc0754a4c8fdd9253d7655fd0 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 10 Sep 2026 22:22:31 +0200 Subject: [PATCH 2/9] Update mutaml_ppx.ml to the AST changes of ppxlib.0.37.0 around functions --- src/ppx/mutaml_ppx.ml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ppx/mutaml_ppx.ml b/src/ppx/mutaml_ppx.ml index 0071e5d..c6a73f1 100644 --- a/src/ppx/mutaml_ppx.ml +++ b/src/ppx/mutaml_ppx.ml @@ -463,10 +463,13 @@ class mutate_mapper (rs : RS.t) = self#mutaml_mutant ctx loc(*e0.pexp_loc*) [%expr ()] e0' (string_of_exp e1) in { e0 with pexp_desc = Pexp_sequence (e0'',e1') } - | _, Pexp_function cases -> - self#cases ctx cases >>| fun cases_pure -> (* all cases are pure in 'function' *) - let function_ = { e with pexp_desc = Pexp_function cases_pure } in - if Match.cases_contain_matching_patterns cases_pure + | _, Pexp_function (params, constrs, fbody) -> + self#function_body ctx fbody >>| fun fbody -> + let function_ = { e with pexp_desc = Pexp_function (params, constrs, fbody) } in + let contains_matching_patterns = (match fbody with + | Pfunction_body _ -> false + | Pfunction_cases (cases_pure,_,_) -> Match.cases_contain_matching_patterns cases_pure) in + if contains_matching_patterns then Exp.attr function_ (* disable pattern-match warning *) { attr_name = {txt = "ocaml.warning"; loc}; @@ -489,6 +492,14 @@ class mutate_mapper (rs : RS.t) = | _ -> super#expression ctx e + method! function_body ctx body = match body with + | Pfunction_body e -> + self#expression ctx e >>| fun e -> + Pfunction_body e + | Pfunction_cases (cases,loc,attrs) -> + self#cases ctx cases >>| fun cases_pure -> (* all cases are pure in 'function' *) + Pfunction_cases (cases_pure,loc,attrs) + (* don't mutate attribute parameters such as 'false' in [@@deriving show {with_path=false}] *) method! attributes _ctx attrs = return attrs From 5b6e7c13ffc68e5e5cc5676e032cb26f4a8051d9 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 10 Sep 2026 22:25:07 +0200 Subject: [PATCH 3/9] Update bound in dune-project and mutaml.opam --- dune-project | 2 +- mutaml.opam | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dune-project b/dune-project index 8417d91..643cb58 100644 --- a/dune-project +++ b/dune-project @@ -30,7 +30,7 @@ (ocaml (>= 4.12.0)) (dune (>= 3.18)) (dune (and (>= 3.22.0) :with-test)) - (ppxlib (and (>= 0.28.0) (< 0.36.0))) + (ppxlib (>= 0.37.0)) (ppx_deriving_yojson (>= 3.7.0)) stdlib-random conf-timeout diff --git a/mutaml.opam b/mutaml.opam index 4758bf7..f3648e5 100644 --- a/mutaml.opam +++ b/mutaml.opam @@ -20,7 +20,7 @@ depends: [ "ocaml" {>= "4.12.0"} "dune" {>= "3.18"} "dune" {>= "3.22.0" & with-test} - "ppxlib" {>= "0.28.0" & < "0.36.0"} + "ppxlib" {>= "0.37.0"} "ppx_deriving_yojson" {>= "3.7.0"} "stdlib-random" "conf-timeout" From d09de15ce97b5e075e61c53d82c54d04b6a7789c Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 10 Sep 2026 22:28:15 +0200 Subject: [PATCH 4/9] Adjust cram tests to ppxlib.0.37.0 --- .../function-merge-consecutive.t | 25 ++++++++++--------- test/negative-tests/ppx-negtests.t | 2 ++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/test/instrumentation-tests/function-merge-consecutive.t b/test/instrumentation-tests/function-merge-consecutive.t index cbc8d2c..e0d3bc8 100644 --- a/test/instrumentation-tests/function-merge-consecutive.t +++ b/test/instrumentation-tests/function-merge-consecutive.t @@ -658,18 +658,19 @@ Same example that triggers merge-of-consecutive-patterns w/GADTs false | X | Lit of int | Binop of aexp * binop * aexp - let rec interpret xval = - ((function - | X -> xval - | Lit i -> i - | Binop (ae0, Add, ae1) when not (__is_mutaml_mutant__ "test:2") -> - let v0 = interpret xval ae0 in - let v1 = interpret xval ae1 in - if __is_mutaml_mutant__ "test:0" then v0 - v1 else v0 + v1 - | Binop (ae0, Add, ae1) | Binop (ae0, Mul, ae1) -> - let v0 = interpret xval ae0 in - let v1 = interpret xval ae1 in - if __is_mutaml_mutant__ "test:1" then v0 + v1 else v0 * v1) + let rec interpret = + ((fun xval -> + function + | X -> xval + | Lit i -> i + | Binop (ae0, Add, ae1) when not (__is_mutaml_mutant__ "test:2") -> + let v0 = interpret xval ae0 in + let v1 = interpret xval ae1 in + if __is_mutaml_mutant__ "test:0" then v0 - v1 else v0 + v1 + | Binop (ae0, Add, ae1) | Binop (ae0, Mul, ae1) -> + let v0 = interpret xval ae0 in + let v1 = interpret xval ae1 in + if __is_mutaml_mutant__ "test:1" then v0 + v1 else v0 * v1) [@ocaml.warning "-8"]) let () = (interpret (if __is_mutaml_mutant__ "test:3" then 3 else 2) diff --git a/test/negative-tests/ppx-negtests.t b/test/negative-tests/ppx-negtests.t index be77ab1..b206b32 100644 --- a/test/negative-tests/ppx-negtests.t +++ b/test/negative-tests/ppx-negtests.t @@ -269,6 +269,8 @@ Instrument and check that it was received -dont-apply Exclude these transformations -cookie NAME=EXPR Set the cookie NAME to EXPR --cookie Same as -cookie + -raise-embedded-errors Raise the first embedded error found in the processed AST + -allow-deriving-end Whether to allow [@@@deriving.end], which will soon be deprecated. -seed Set randomness seed for mutaml's instrumentation -mut-rate Set probability in % of mutating a syntax tree node (default: 50%) -gadt Allow only pattern mutations compatible with GADTs (default: true) From 6e5c1dd899a2210066fe143ecbaf5513ccb94677 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 10 Sep 2026 23:12:34 +0200 Subject: [PATCH 5/9] Update dune bound to 3.22.0 in dune-project and mutaml.opam --- dune-project | 4 +--- mutaml.opam | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/dune-project b/dune-project index 643cb58..3411d5c 100644 --- a/dune-project +++ b/dune-project @@ -1,4 +1,4 @@ -(lang dune 3.18) +(lang dune 3.22) (name mutaml) @@ -28,8 +28,6 @@ (tags ("test" "mutation testing")) (depends (ocaml (>= 4.12.0)) - (dune (>= 3.18)) - (dune (and (>= 3.22.0) :with-test)) (ppxlib (>= 0.37.0)) (ppx_deriving_yojson (>= 3.7.0)) stdlib-random diff --git a/mutaml.opam b/mutaml.opam index f3648e5..253b2cd 100644 --- a/mutaml.opam +++ b/mutaml.opam @@ -17,9 +17,8 @@ homepage: "https://github.com/jmid/mutaml" doc: "https://github.com/jmid/mutaml" bug-reports: "https://github.com/jmid/mutaml/issues" depends: [ + "dune" {>= "3.22"} "ocaml" {>= "4.12.0"} - "dune" {>= "3.18"} - "dune" {>= "3.22.0" & with-test} "ppxlib" {>= "0.37.0"} "ppx_deriving_yojson" {>= "3.7.0"} "stdlib-random" From a95b3b9e131e36973cdad912b97290e09794f35c Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 10 Sep 2026 23:14:20 +0200 Subject: [PATCH 6/9] Add an ocaml.5.4 upper bound for with-test --- dune-project | 1 + mutaml.opam | 1 + 2 files changed, 2 insertions(+) diff --git a/dune-project b/dune-project index 3411d5c..b36c478 100644 --- a/dune-project +++ b/dune-project @@ -28,6 +28,7 @@ (tags ("test" "mutation testing")) (depends (ocaml (>= 4.12.0)) + (ocaml (and (< 5.4.0) :with-test)) (ppxlib (>= 0.37.0)) (ppx_deriving_yojson (>= 3.7.0)) stdlib-random diff --git a/mutaml.opam b/mutaml.opam index 253b2cd..30ea207 100644 --- a/mutaml.opam +++ b/mutaml.opam @@ -19,6 +19,7 @@ bug-reports: "https://github.com/jmid/mutaml/issues" depends: [ "dune" {>= "3.22"} "ocaml" {>= "4.12.0"} + "ocaml" {< "5.4.0" & with-test} "ppxlib" {>= "0.37.0"} "ppx_deriving_yojson" {>= "3.7.0"} "stdlib-random" From 018d7354dce6ac15b79a8dcfb3b8a4c2b18b0f59 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 10 Sep 2026 23:15:18 +0200 Subject: [PATCH 7/9] Add a CHANGES entry --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index cb658ff..efa1a32 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ Next release ------------ +- Support ppxlib 0.37 and 0.38 and require dune.3.22.0 #49 - Adjust test suite to be compatible with >= dune.3.22.0 #48 - Switch to using `ppx_deriving_yojson` instead of `ppx_yojson_conv` #47 - Use dune.3.18 support to generate `x-maintenance-intent` entry #45 From 17aaa2de15b9f89a871c3e8200883d6e395a2894 Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 10 Sep 2026 23:31:13 +0200 Subject: [PATCH 8/9] Lower the ocaml with-test upper bound to 5.3.0 --- dune-project | 2 +- mutaml.opam | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dune-project b/dune-project index b36c478..dfc4a7d 100644 --- a/dune-project +++ b/dune-project @@ -28,7 +28,7 @@ (tags ("test" "mutation testing")) (depends (ocaml (>= 4.12.0)) - (ocaml (and (< 5.4.0) :with-test)) + (ocaml (and (< 5.3.0) :with-test)) (ppxlib (>= 0.37.0)) (ppx_deriving_yojson (>= 3.7.0)) stdlib-random diff --git a/mutaml.opam b/mutaml.opam index 30ea207..e052224 100644 --- a/mutaml.opam +++ b/mutaml.opam @@ -19,7 +19,7 @@ bug-reports: "https://github.com/jmid/mutaml/issues" depends: [ "dune" {>= "3.22"} "ocaml" {>= "4.12.0"} - "ocaml" {< "5.4.0" & with-test} + "ocaml" {< "5.3.0" & with-test} "ppxlib" {>= "0.37.0"} "ppx_deriving_yojson" {>= "3.7.0"} "stdlib-random" From 52addde32131381a8b17a42e3fa6f42bd17a931c Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Mon, 14 Sep 2026 21:38:43 +0200 Subject: [PATCH 9/9] Lower the ocaml with-test upper bound to 5.2.0 --- dune-project | 2 +- mutaml.opam | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dune-project b/dune-project index dfc4a7d..3daa0b8 100644 --- a/dune-project +++ b/dune-project @@ -28,7 +28,7 @@ (tags ("test" "mutation testing")) (depends (ocaml (>= 4.12.0)) - (ocaml (and (< 5.3.0) :with-test)) + (ocaml (and (< 5.2.0) :with-test)) (ppxlib (>= 0.37.0)) (ppx_deriving_yojson (>= 3.7.0)) stdlib-random diff --git a/mutaml.opam b/mutaml.opam index e052224..6449790 100644 --- a/mutaml.opam +++ b/mutaml.opam @@ -19,7 +19,7 @@ bug-reports: "https://github.com/jmid/mutaml/issues" depends: [ "dune" {>= "3.22"} "ocaml" {>= "4.12.0"} - "ocaml" {< "5.3.0" & with-test} + "ocaml" {< "5.2.0" & with-test} "ppxlib" {>= "0.37.0"} "ppx_deriving_yojson" {>= "3.7.0"} "stdlib-random"