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

Assertion failure in typing/printtyp.ml line 583-ish #6836

Closed
vicuna opened this issue Apr 9, 2015 · 10 comments
Closed

Assertion failure in typing/printtyp.ml line 583-ish #6836

vicuna opened this issue Apr 9, 2015 · 10 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Apr 9, 2015

Original bug ID: 6836
Reporter: dsheets
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:47:33Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.1
Target version: 4.02.2+dev / +rc1
Fixed in version: 4.02.2+dev / +rc1
Category: typing
Monitored by: @diml

Bug description

When typing the function at < mirage/ocaml-cohttp@c429f5e#diff-19a3a7db54ab863fd07186df30450b0eR37 >, instead of a type error, an assertion failure occurs < https://travis-ci.org/mirage/ocaml-cohttp/jobs/57781176#L3082 >:

Fatal error: exception File "typing/printtyp.ml", line 583, characters 12-18: Assertion failed

Steps to reproduce

  1. git clone git@github.com:dsheets/ocaml-cohttp.git
  2. cd ocaml-cohttp
  3. git checkout request_uri
  4. ocaml setup.ml -configure --enable-tests
  5. make test

Additional information

The same assertion (on slightly different lines) is triggered by this same code in 4.01.0, 4.02.1, and 4.03.0+trunk.

I'm sorry I don't have a more reduced test case available. Reduction would be easiest with an instrumented compiler.

@vicuna
Copy link
Author

vicuna commented Apr 9, 2015

Comment author: dsheets

Ugh. Those links should be mirage/ocaml-cohttp@c429f5e#diff-19a3a7db54ab863fd07186df30450b0eR37 and https://travis-ci.org/mirage/ocaml-cohttp/jobs/57781176#L3082 because '>' is not a valid URI character and is traditionally used to indicate the end of a URI.

@vicuna
Copy link
Author

vicuna commented Apr 9, 2015

Comment author: dsheets

The following crashes utop (but not the toplevel) with the same exception:

module M = struct type 'a t = 'a let return a = a end

module F(M : sig
type 'a t
val return : 'a -> 'a t
end) : sig
val q : unit -> [ Ok ] M.t end = struct let q () = M.return Ok
end

module A = F(M)
;;

A.q ();;

@vicuna
Copy link
Author

vicuna commented Apr 9, 2015

Comment author: dsheets

This issue was reported as a utop issue about 1 year ago by nojb: ocaml-community/utop#60

@vicuna
Copy link
Author

vicuna commented Apr 9, 2015

Comment author: @yallop

You can crash the toplevel or ocamlc if you pass -short-paths:

$ cat bug.ml
module M = struct type 'a t = 'a end

module F(M : sig type 'a t end) : sig
val q : unit -> [ `Ok ] M.t
end = struct
let q () = assert false
end

module A = F(M)

let f () = A.q ()
$ ocamlc -i -short-paths bug.ml
Fatal error: exception File "typing/printtyp.ml", line 583, characters 12-18: Assertion failed

@vicuna
Copy link
Author

vicuna commented Apr 9, 2015

Comment author: dsheets

In my initial case, removing -short-paths avoids the assertion error and there is no masked type error. In this case, using -short-paths prevents an otherwise correct ml file from being built into a cmo.

@vicuna
Copy link
Author

vicuna commented Apr 9, 2015

Comment author: @damiendoligez

For future reference, I needed the following commands to trigger the repro case:

git clone https://github.com/dsheets/ocaml-cohttp.git
cd ocaml-cohttp
git checkout c429f5ea47b2792a4c3e2136a6ca8c3557031c9c
opam install cohttp.0.15.2 --deps-only
opam install magic-mime
ocaml setup.ml -configure --enable-tests
make test

@vicuna
Copy link
Author

vicuna commented Apr 10, 2015

Comment author: @yallop

In my initial case, removing -short-paths avoids the assertion error and there is no masked type error. In this case, using -short-paths prevents an otherwise correct ml file from being built into a cmo.

I'm not sure I understand the distinction (if there is a distinction). It appears that in both cases using -short-paths triggers an assertion error, aborting the compilation of a correct program.

@vicuna
Copy link
Author

vicuna commented Apr 10, 2015

Comment author: dsheets

There is no grand distinction. In your example bug.ml, without -i, the cmo builds fine. I was just wanting to make clear that the assertion error can occur even when type printing is not obviously involved. In that case (the original), an otherwise correct program is not built.

@vicuna
Copy link
Author

vicuna commented Apr 10, 2015

Comment author: @yallop

Ah, I see. Either -i or -annot will trigger the problem, I think.

@vicuna
Copy link
Author

vicuna commented Apr 13, 2015

Comment author: @garrigue

Wrong assumption...

Fixed in trunk and 4.02 at revisions 16013 and 16014.

Note that outcometree is actually incorrect: it requires the row name to be a constructor, but the parser allows any type expression. Fixing this would simplify the code.

@vicuna vicuna closed this as completed Dec 7, 2016
@vicuna vicuna added the typing label Mar 14, 2019
@vicuna vicuna added this to the 4.02.2 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 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