Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] use proper error reporting for toplevel's environment initialization #6401

Closed
vicuna opened this issue May 7, 2014 · 2 comments
Closed
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented May 7, 2014

Original bug ID: 6401
Reporter: @gasche
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2017-02-16T14:16:19Z)
Resolution: fixed
Priority: low
Severity: feature
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: tools (ocaml{lex,yacc,dep,debug,...})
Tags: patch
Monitored by: @hcarty

Bug description

When hacking on the compiler itself, a classic failure when running the toplevel is that it tries to link against the installed standard library instead of the one being modified, which gives various interface mismatches -- the fix is to pass "-I stdlib -nostdlib", and I also need "-noinit" for other reasons.

On trunk, the reporting is currently not very nice (there might be a regression from older versions):

% ./byterun/ocamlrun ./ocaml
OCaml version 4.02.0+dev5-2014-04-29

Fatal error: exception Env.Error(_)

The attached patch calls the error-reporting routines to print a better error message:

% ./byterun/ocamlrun ./ocaml
OCaml version 4.02.0+dev5-2014-04-29

File "none", line 1:
Error: The files ./ocaml
and /home/gabriel/.opam/4.02.0local+git-trunk/lib/ocaml/pervasives.cmi
make inconsistent assumptions over interface Pervasives

Additional information

The patch is careful to only catch Env.Error exceptions, so as not to trash the backtraces of other, unplanned-for failures. After catching and reporting the exception, it terminates with "exit 2":

  • keeping an uninitialized toplevel alive makes no sense
  • re-raising the exception seems useless (the backtrace is trashed) and potentially confusing
  • "2" was already used as an error code in topmain.ml

File attachments

@vicuna
Copy link
Author

vicuna commented May 7, 2014

Comment author: @johnwhitington

Excellent. I knew I must have been missing something simple, but no-one seemed to know!

http://sympa.inria.fr/sympa/arc/caml-list/2014-01/msg00017.html

@vicuna
Copy link
Author

vicuna commented Dec 2, 2015

Comment author: @alainfrisch

I've merged the patch to trunk, also capturing Typetexp.Error. This allows to get:

$ boot/ocamlrun ./ocaml
OCaml version 4.03.0+dev11-2015-10-19

File "command line", line 1:
Error: Unbound module Pervasives

@vicuna vicuna closed this as completed Feb 16, 2017
@vicuna vicuna added the tools label Mar 14, 2019
@vicuna vicuna added this to the 4.03.0 milestone Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants