Instrumentation and preprocessing
Opened this issue ยท 3 comments
Hello, It seems that the instrumentation is launched before the preprocessor, generating errors in some cases.
Here is a minimalistic example with sedlex preprocessing :
$ git clone https://github.com/jmid/mutaml.git
$ cd mutaml
$ opam install .
$ cd ..
$ git clone https://github.com/epatrizio/mutaml_exp.git
$ cd mutaml_exp
$ dune runtest --instrument-with mutaml
File "lib/dune", line 4, characters 2-18:
4 | (pps sedlex.ppx))
^^^^^^^^^^^^^^^^
Running mutaml instrumentation on "lib/lib.ml"
Randomness seed: 374585493 Mutation rate: 50 GADTs enabled: true
Created 4 mutations of lib/lib.ml
Writing mutation info to lib/lib.muts
File "lib/lib.ml", line 12, characters 4-24:
12 | | "hello" -> token buf
^^^^^^^^^^^^^^^^^^^^
Error: Sedlex: 'when' guards are not supported
What happens is that mutaml
inserts some when
guards on a branch from a match%sedlex
construct. Sedlex then complains because it can not handle such guards.
I don't know if it's possible to tell dune to instrument the code only after preprocessing ? Otherwise, should the instrumentation tool (mutaml
) be careful and not modify code that contains preprocessing annotations ?
Thanks a lot!
Acknowledged! Thanks for the report and the small repro ๐
Sorry, the details of ppxlib
are a bit hazy ATM... ๐
I suspect this is due to
Line 64 in 4a3e83f
As an experiment could you try changing it to After
instead?
I don't know if it's possible to tell dune to instrument the code only after preprocessing ? Otherwise, should the instrumentation tool (mutaml) be careful and not modify code that contains preprocessing annotations ?
Yep, I suspect something like that would be preferable.
In the present case we don't want Before
- but I don't think we want After
either, as that would enable mutations of preprocessor-generated code that a developer is not writing themself... ๐ค
It seems to work with After
, thanks !
Indeed, I'm not sure we want to instrument code that has been generated by a preprocessor. Maybe we could just keep Before
and ignore code that is annotated ?
Same on my small example, it works with After
, thanks!