ocaml / oloop

Evaluate code through the OCaml toploop for inclusion in educational material.
ISC License
12 stars 5 forks source link

test with OCaml 4.02 #33

Open agarwal opened 9 years ago

agarwal commented 9 years ago

Here's one example of an unexpected failure:

$ cat a.ml 
#use "topfind";;
#thread;;
#camlp4o;;
#require "core";;
#require "core.syntax";;
open Core_kernel.Std;;

$ oloop a.ml -silent-directives
(* part 0 *)
# #use "topfind";;

# #thread;;

# #camlp4o;;

# #require "core";;
Error: Reference to undefined global `Lazy'

# #require "core.syntax";;
Error: Reference to undefined global `Lazy'

# open Core_kernel.Std;;
Error: Unbound module Core_kernel
Chris00 commented 9 years ago

With commit 5708386, this becomes:

./app.native -silent-directives a.ml 
(* part 0 *)
# #use "topfind";;

# #thread;;

# #camlp4o;;

# #require "core";;

# #require "core.syntax";;
Error: Reference to undefined global `Camlp4'

# open Core_kernel.Std;;
Chris00 commented 9 years ago

The above error is what happens when run in the Oloop directory because .ocamlinit gets picked up. If one runs in another directory or if ./app.native -silent-directives -noinit a.ml is used, everything seems OK.

agarwal commented 9 years ago

I see. But there is still some oddity. I don't see why running the .ocamlinit file should cause any error, and utop gets this right but the normal ocaml toploop doesn't.

Within the working directory's root:

$ utop
utop # #use "a.ml";;
(* no errors *)
$ ocaml
# #use "tmp/a.ml";;
...
/Users/ashish/.opam/4.02.3/lib/fieldslib/pa_fields_conv.cma: loaded
File "tmp/a.ml", line 1:
Error: Reference to undefined global `Camlp4'

I guess this is not an oloop problem then, but any idea what's happening?