fix two minor stale locations (Location.none) in typemod.ml

The two bewildering "_none_" error messages fixed by this commit
could be observed in the following way:
  echo "let f (x, y) = x + 1" > test.ml
  touch test.mli
  ocamlc -c -annot test.ml
    File "_none_", line 1:
    Error: Could not find the .cmi file for interface test.mli.
  grep "def f" test.annot
    def f "test.ml" 1 0 20 "_none_" 1 0 -1

Behavior after the fixes:
  echo "let f (x, y) = x + 1" > test.ml
  touch test.mli
  ocamlc -c -annot test.ml
    File "test.ml", line 1:
    Error: Could not find the .cmi file for interface test.mli.
  grep "def f" test.annot
    def f "test.ml" 1 0 20 "test.ml" 1 0 -1

One could argue that for the "could not find the .cmi" error, the file
chosen could be test.mli. I find it more natural to have the name of
the file that the user asked to compile (and therefore provoked the
error). Any of those choices is better than "_none_" anyway.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13091 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Gabriel Scherer 2012-11-11 10:59:43 +00:00
parent e41b5df033
commit 35160d3712
1 changed files with 4 additions and 2 deletions

View File

@ -1254,7 +1254,8 @@ let type_implementation sourcefile outputprefix modulename initial_env ast =
Cmt_format.set_saved_types [];
try
Typecore.reset_delayed_checks ();
let (str, sg, finalenv) = type_structure initial_env ast Location.none in
let (str, sg, finalenv) =
type_structure initial_env ast (Location.in_file sourcefile) in
let simple_sg = simplify_signature sg in
if !Clflags.print_types then begin
fprintf std_formatter "%a@." Printtyp.signature simple_sg;
@ -1267,7 +1268,8 @@ let type_implementation sourcefile outputprefix modulename initial_env ast =
try
find_in_path_uncap !Config.load_path (modulename ^ ".cmi")
with Not_found ->
raise(Error(Location.none, Interface_not_compiled sourceintf)) in
raise(Error(Location.in_file sourcefile,
Interface_not_compiled sourceintf)) in
let dclsig = Env.read_signature modulename intf_file in
let coercion = Includemod.compunit sourcefile sg intf_file dclsig in
Typecore.force_delayed_checks ();