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

Unhandled exception from List.nth when using -short-paths with ill-typed code #7543

Closed
vicuna opened this issue May 29, 2017 · 3 comments
Closed

Comments

@vicuna
Copy link

vicuna commented May 29, 2017

Original bug ID: 7543
Reporter: @jberdine
Assigned to: @Octachron
Status: resolved (set by @mshinwell on 2017-06-09T17:03:19Z)
Resolution: duplicate
Priority: normal
Severity: crash
Version: 4.04.1
Category: typing

Bug description

It seems that ill-typed code can cause -short-paths to raise instead of detecting the error.

Steps to reproduce

$ cat repro.ml
open Base

let e = Set.empty (module Comparator.Poly)
$ ocamlc -I ~/.opam/4.04.1/lib/base repro.ml
File "repro.ml", line 3, characters 26-41:
Error: Signature mismatch:
       ...
       Type declarations do not match:
         type 'a t = 'a
       is not included in
         type t = Base.Comparator.Poly.t
       They have different arities.
$ ocamlc -I ~/.opam/4.04.1/lib/base repro.ml -short-paths
Fatal error: exception Failure("nth")
$ OCAMLRUNPARAM=b ocamlc -I ~/.opam/4.04.1/lib/base repro.ml -short-paths
Fatal error: exception Failure("nth")
Raised at file "pervasives.ml", line 32, characters 17-33
Called from file "typing/printtyp.ml", line 235, characters 15-30
Called from file "typing/printtyp.ml", line 489, characters 43-62
Called from file "typing/printtyp.ml", line 803, characters 8-21
Called from file "typing/printtyp.ml", line 905, characters 13-38
Called from file "typing/printtyp.ml", line 908, characters 27-72
Called from file "format.ml", line 1187, characters 4-20
Called from file "format.ml", line 1200, characters 32-48
Called from file "format.ml", line 1200, characters 32-48
Called from file "format.ml", line 1187, characters 4-20
Called from file "format.ml", line 1248, characters 20-38
Called from file "typing/includemod.ml", line 529, characters 6-343
Called from file "format.ml", line 1187, characters 4-20
Called from file "format.ml", line 1248, characters 20-38
Called from file "utils/misc.ml", line 28, characters 20-27
Re-raised at file "utils/misc.ml", line 28, characters 50-57
Called from file "utils/misc.ml", line 40, characters 10-14
Re-raised at file "utils/misc.ml", line 42, characters 38-45
Called from file "format.ml", line 1187, characters 4-20
Called from file "format.ml", line 1248, characters 20-38
Called from file "format.ml", line 1187, characters 4-20
Called from file "format.ml", line 1248, characters 20-38
Called from file "utils/misc.ml", line 28, characters 20-27
Re-raised at file "utils/misc.ml", line 28, characters 50-57
Called from file "utils/misc.ml", line 40, characters 10-14
Re-raised at file "utils/misc.ml", line 42, characters 38-45
Called from file "format.ml", line 1187, characters 4-20
Called from file "format.ml", line 1248, characters 20-38
Called from file "parsing/location.ml" (inlined), line 415, characters 2-28
Called from file "typing/typemod.ml", line 1830, characters 13-67
Called from file "parsing/location.ml", line 384, characters 14-19
Called from file "parsing/location.ml", line 447, characters 12-28
Re-raised at file "parsing/location.ml", line 450, characters 12-23
Re-raised at file "parsing/location.ml", line 450, characters 12-23
Re-raised at file "parsing/location.ml", line 450, characters 12-23
Re-raised at file "parsing/location.ml", line 450, characters 12-23
Re-raised at file "parsing/location.ml", line 450, characters 12-23
Called from file "parsing/location.ml" (inlined), line 454, characters 31-61
Called from file "driver/main.ml", line 190, characters 4-35
Called from file "utils/timings.ml", line 69, characters 10-13
Called from file "driver/main.ml", line 194, characters 2-28
$
@vicuna
Copy link
Author

vicuna commented May 29, 2017

Comment author: @jberdine

Sorry, the repro was unnecessarily not self-contained. Here is a smaller one:

module type S = sig type t end

let f ((module M) : (module S with type t = unit)) = ()

module N = struct type 'a t = 'a end

let x = f (module N)

Also, I checked that it repros with the 4.05.0+trunk opam switch.

@vicuna
Copy link
Author

vicuna commented May 30, 2017

Comment author: @Octachron

Thanks for the report (and the reduced test case)! I have proposed a minimal fix to the issue in #1186 .

@vicuna
Copy link
Author

vicuna commented Jun 9, 2017

Comment author: @mshinwell

Please continue discussion on the Github issue.

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