# Bug in ppx processing: works with -dump-ast but not without it

**URL:** https://discuss.ocaml.org/t/bug-in-ppx-processing-works-with-dump-ast-but-not-without-it/10668
**Category:** Ecosystem
**Tags:** ppx
**Created:** [October 21, 2022, 4:04pm UTC](https://discuss.ocaml.org/t/bug-in-ppx-processing-works-with-dump-ast-but-not-without-it/10668 "2022-10-21T16:04:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mobileink](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mobileink/32/3295_2.png) [@mobileink](https://discuss.ocaml.org/u/mobileink)
#### Post date: [October 21, 2022, 4:04pm UTC](https://discuss.ocaml.org/t/bug-in-ppx-processing-works-with-dump-ast-but-not-without-it/10668/1 "2022-10-21T16:04:32Z")

</div>

I’m building js\_of\_ocaml with Bazel and I’ve found a discrepancy in ppx processing with and without `-dump-ast`.

Building `lib/js_of_ocaml/js_of_ocaml.cmxa` succeeds if I pass `-dump-ast` to the ppx that transforms all of its submodules. This is the default. But for debugging, I can omit that option so that the ppx transform emits text rather than binary files (cli flag `--@rules_ocaml//ppx/print=text` controls this globally). But when I do this I get the following error:

```auto
File "bazel-out/darwin-fastbuild-ST-a36c911cac36/bin/lib/js_of_ocaml/ __obazl/Js_of_ocaml__ Dom.mli", line 176, characters 31-32:
176 | val eventTarget : < .. > as 'a#event t -> 'a t[@@ocaml.doc
                                     ^
Error: Syntax error

```

So the effect of the ppx transform seems to vary depending on whether output is set to binary or text.

I think this is a bug somewhere in the ppx code, rather than the build code, but I don’t know the ppx machinery well enough to debug it, and I’m not sure where I should report it. Advice?

Thanks,

Gregg

---

<div class="post-metadata">

### Author: ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)
#### Post date: [October 21, 2022, 4:21pm UTC](https://discuss.ocaml.org/t/bug-in-ppx-processing-works-with-dump-ast-but-not-without-it/10668/2 "2022-10-21T16:21:45Z")

</div>

This is a bug in the `Pprintast` pretty-printer which output the parsetree AST in text format, as you can test with

```ocaml
class ['a] c = object end
module type t = sig val x: (< .. > as 'a) #c end

```

Using `-dsource` on this output prints

```ocaml
module type t = sig val x : < .. > as 'a#c end;

```

reproducing your syntax error.  
You can report the issue directlu on the OCaml bugtracker.
