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

compiler crashes on crazy types #4775

Closed
vicuna opened this issue Apr 23, 2009 · 3 comments
Closed

compiler crashes on crazy types #4775

vicuna opened this issue Apr 23, 2009 · 3 comments
Assignees
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 23, 2009

Original bug ID: 4775
Reporter: cfalls
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2011-05-29T10:14:12Z)
Resolution: fixed
Priority: normal
Severity: crash
Version: 3.11.0
Fixed in version: 3.11.1+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @yakobowski

Bug description

The following program crashes several versions of the compiler. I discovered this bug when fiddling around with type constraints -- I doubt it would be triggered by any program that was written to do something useful.

=============== ~/bug2.ml ====================
module type Poly = sig
type 'a t = 'a constraint 'a = [> ]
end

module Combine (A : Poly) (B : Poly) = struct
type ('a, 'b) t = 'a A.t constraint 'a = 'b B.t
end

module C = Combine
(struct type 'a t = 'a constraint 'a = [> ] end)
(struct type 'a t = 'a constraint 'a = [> ] end)
=============== ~/bug2.ml ====================

/janelibs/ocaml-3.11.0+jane3_64/bin/ocaml ~/bug2.ml
Fatal error: exception Ctype.Unify(_, _)
(Program not linked with -g, cannot print stack backtrace)

/janelibs/ocaml-3.11.0+jane3_64/bin/ocaml -version
The Objective Caml toplevel, version 3.11.0+jane3

/usr/local/home/godi310/godi/bin/ocaml ~/bug2.ml
Fatal error: exception Ctype.Unify(_, _)
(Program not linked with -g, cannot print stack backtrace)

/usr/local/home/godi310/godi/bin/ocaml -version
The Objective Caml toplevel, version 3.10.1+dev0 (2007-05-21)

@vicuna
Copy link
Author

vicuna commented Apr 27, 2009

Comment author: @garrigue

Thanks for this interesting report.
Indeed your crazy types are not crazy at all, and
I believe the code you describe should be accepted.
But the cause of the bug, in Ctype.nondep_type_rec, is the use
of unification in expand_abbrev combined with a special representation
with Tsubst nodes, which was introduced about 10 years ago, so I believe
that no version since 2.99 can compile it.
It would be interesting to see whether ocaml 2.04 can compile it, as
I have my doubt about the correctness of the previous code too.

I'm still looking for a workaround...

@vicuna
Copy link
Author

vicuna commented May 19, 2009

Comment author: @garrigue

Actually the first explanation was wrong. The real trouble here is
the use of a curried functor. If you uncurry it (use two submodules as argument),
then this program is accepted. A real fix would be either in Mtype or Typemod.

As a temporary fix, I catch Unify in Ctype.nondep_type_rec.
Curiously, this does not results in a failure, but just in making t abstract
in the result.

@vicuna
Copy link
Author

vicuna commented May 19, 2009

Comment author: @garrigue

A better solution is now commited in head branch (3.12+dev),
solving both the problem with nondep_type (do not modify types during copying)
and Mtype.nondep_mty (extend environment when eliminating in functors).
Your example is now typable with this version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants