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 triggered by recursive class type #6496

Closed
vicuna opened this issue Jul 23, 2014 · 3 comments
Closed

Assertion triggered by recursive class type #6496

vicuna opened this issue Jul 23, 2014 · 3 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Jul 23, 2014

Original bug ID: 6496
Reporter: choeger
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:34:33Z)
Resolution: duplicate
Priority: normal
Severity: major
Platform: x86
OS: Linux
OS Version: 3.15.4
Version: 4.01.0
Target version: 4.02.1+dev
Category: typing
Child of: #6505

Bug description

The following class type leads to a hard crash of the typechecker:

type 'r foo_t = <get : 'r bar option ; set : 'r bar option -> 'r; ..> as 'r

and 'r bar
constraint 'r = 'r foo_t

class c : object('r)
constraint 'r = 'r foo_t
method get : 'r bar option
method set : 'r bar option -> 'r
end = object(self: 'r)
constraint 'r = 'r foo_t
val _bar : 'r bar option = None
method get = _bar
method set b = {< _bar = b >}
end

Steps to reproduce

Either run ocamlc on the above interface:

ocamlc -o test.cmi test.mli

or #use the following implementation in a toplevel:

type 'r foo_t = <get : 'r bar option ; set : 'r bar option -> 'r; ..> as 'r

and 'r bar
constraint 'r = 'r foo_t

class c : object('r)
constraint 'r = 'r foo_t
method get : 'r bar option
method set : 'r bar option -> 'r
end = object(self: 'r)
constraint 'r = 'r foo_t
val _bar : 'r bar option = None
method get = _bar
method set b = {< _bar = b >}
end

Additional information

In any case, the crash is:

Fatal error: exception Assert_failure("typing/ctype.ml", 245, 27)

@vicuna
Copy link
Author

vicuna commented Jul 23, 2014

Comment author: @lpw25

Smaller example:

type 'r foo = 'r constraint 'r = <m : 'r bar; ..>
and 'r bar constraint 'r = 'r foo

class type c = object('r)
  method m : 'r bar
end

@vicuna
Copy link
Author

vicuna commented Jul 30, 2014

Comment author: @damiendoligez

Downgrading this to "major" because it's only a compiler failure, not a crash of the user program.

@vicuna
Copy link
Author

vicuna commented Aug 21, 2014

Comment author: @garrigue

The source of the problem is the same as #6505, and it is already fixed in 4.02.

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