jmid / mutaml

An OCaml mutation tester
BSD 2-Clause "Simplified" License
65 stars 4 forks source link

Breaks with ppx_deriving's `show` #28

Closed WardBrian closed 1 month ago

WardBrian commented 2 months ago

I was interested in trying this with a large code-base (https://github.com/stan-dev/stanc3) but ran into a few compile-time errors. This seems to be independent of #9, as editing the line in entry.ml has no effect for me.

The simplest error that arises is

File "src/middle/Stan_math_signatures.ml", line 87, characters 29-34:
87 | [@@deriving show {with_path= false}]
                                  ^^^^^
Error: show: boolean expected

I also got a stranger one, which isn't immediately tied to any ppx as far as I can tell:

File "src/common/Foldable.ml", line 66, characters 25-30:
66 |   let any ~pred ?(init = false) x =
                              ^^^^^
Error: This expression has type string option
       but an expression was expected of type int
jmid commented 2 months ago

Thanks for the report! I've looked into the former for a start. #29 should offer a fix.

jmid commented 2 months ago

I've now merged #29 and had a look at the second one.

The issue there is that the ppx is emitting a polymorphic comparison = between string options, which after open Core is redefined to an integer comparison function int -> int -> bool, thus leading to a type error in the generated code... :shrug: Emitting a call to Option.equal String.equal instead should fix it.

WardBrian commented 2 months ago

Ah, that can also be fixed by changing our code to open Core.Poly (I think we do something similar to make Menhir happy), but it would be nice if that wasn’t necessary

WardBrian commented 2 months ago

I think you can also emit Stdlib.( = ), if the polymorphic compare is important?

jmid commented 1 month ago

I've now opened #30 to address the second issue. I hope this helps. Thanks again for the report!

WardBrian commented 1 month ago

The build now works. Thanks!