loading type_conv causes error

82 views
Skip to first unread message

Ashish Agarwal

unread,
Sep 30, 2015, 12:04:26 PM9/30/15
to ocaml...@googlegroups.com
I have library foolib, which works fine in most cases, except when I also load type_conv in a certain way.

I install this library with opam, and load it:

$ utop
# #require "foolib";;
(* no error *)


Adding type_conv causes an error:

# #require "type_conv foolib";;
File "", line 1, characters 0-4:
Error: Parse error: illegal begin of top_phrase
Fatal error: exception Exit                                                                         
Raised at file "bytes.ml", line 220, characters 25-34


Furthermore, it depends on exactly when I load type_conv. The following works:

# #require "foolib";;
# #require "type_conv foolib";;
(* no error *)

I also tried loading type_conv, followed by loading the foolib.cma directly, and that also works fine.

The location referred to in the bytes.ml file isn't helping me much. It is an out-of-bounds error, but I have no idea how one would get there.

Any idea how to debug a problem like this?

Ashish Agarwal

unread,
Sep 30, 2015, 1:25:01 PM9/30/15
to ocaml...@googlegroups.com
I've produced a minimal example:

Ashish Agarwal

unread,
Sep 30, 2015, 1:30:30 PM9/30/15
to ocaml...@googlegroups.com
I also don't get this error from the normal `ocaml` toplevel.

Ashish Agarwal

unread,
Oct 2, 2015, 12:41:30 PM10/2/15
to ocaml...@googlegroups.com
Possibly answering my own question: I guess type_conv is incompatible since it uses camlp4, and foolib is using some ppx stuff. Not sure, but it seems removing all camlp4 stuff fixes my issue. A little annoying that the behavior is so dependent on the specific order in which libraries are loaded.

Jeremie Dimino

unread,
Oct 2, 2015, 1:26:02 PM10/2/15
to ocaml...@googlegroups.com
I was able to reproduce it with a smaller example:

utop # #require "camlp4 ppx_core";;
File "", line 1, characters 0-4:
Error: Parse error: illegal begin of top_phrase
Fatal error: exception Pervasives.Exit
Called from file "src/lib/uTop.cppo.ml", line 108, characters 2-11
Called from file "src/lib/uTop_main.cppo.ml", line 660, characters 21-61
Called from file "src/lib/uTop_main.cppo.ml", line 1319, characters 8-17
Called from file "src/lib/uTop_main.cppo.ml", line 1334, characters 4-15

Exit seems to be raised by  `Location.report_exception`. I can also reproduce it in the normal toplevel with:

# #camlp4o;;
/home/jdimino/code/opam-root/4.02.3/lib/ocaml/dynlink.cma: loaded
/home/jdimino/code/opam-root/4.02.3/lib/ocaml/camlp4: added to search path
/home/jdimino/code/opam-root/4.02.3/lib/ocaml/camlp4/camlp4o.cma: loaded
Camlp4 Parsing version 4.02.3

# #require "ppx_core";;
/home/jdimino/code/opam-root/4.02.3/lib/ocaml/compiler-libs: added to search path
/home/jdimino/code/opam-root/4.02.3/lib/ocaml/compiler-libs/ocamlcommon.cma: loaded
/home/jdimino/code/opam-root/4.02.3/lib/ppx_core: added to search path
File "", line 1, characters 0-4:
Error: Parse error: illegal begin of top_phrase
Fatal error: exception Pervasives.Exit
(Program not linked with -g, cannot print stack backtrace)


--
You received this message because you are subscribed to the Google Groups "ocaml-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ocaml-core+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jeremie

Ashish Agarwal

unread,
Oct 5, 2015, 1:11:11 PM10/5/15
to ocaml...@googlegroups.com
I think you're saying the bug is in ppx_core. I guess I won't hit it as long as I completely avoid camlp4, so I should be fine. Thanks.

Jeremie Dimino

unread,
Oct 5, 2015, 1:26:39 PM10/5/15
to ocaml...@googlegroups.com
On Mon, Oct 5, 2015 at 6:10 PM, Ashish Agarwal <agarw...@gmail.com> wrote:
> I think you're saying the bug is in ppx_core. I guess I won't hit it as long
> as I completely avoid camlp4, so I should be fine. Thanks.

Well, it seems to be triggered by ppx_core. But I suspect it's more a
problem due to the fact ppx_core depends on compiler-libs.common.

--
Jeremie
Reply all
Reply to author
Forward
0 new messages