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

Uncuaght CType.Unify exception #5619

Closed
vicuna opened this issue May 18, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented May 18, 2012

Original bug ID: 5619
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @garrigue on 2012-05-25T05:22:19Z)
Resolution: fixed
Priority: low
Severity: crash
Fixed in version: 4.00.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #5545 #6123
Monitored by: @lpw25 mehdi

Bug description

Compiling the following code produces an uncaught CType.Unify exception:

exception Bad_cast

class type foo_t =
object
method foo: string
end

type 'a name =
Foo: foo_t name
| Int: int name

class foo: foo_t =
object(self)
method foo = "foo"
method cast: type a. a name -> a =
function
Foo -> (self :> foo_t)
| _ -> ((raise Bad_cast) : a)
end

I am using revision 12464 from the repository.

I know that this code is not valid. The original code used my "open types" extension, but I had to remove those bits to show that the bug was not in my extension.

The bug could be avoided in my original code by changing (self :> foo_t) to (self : #foo_t :> foo_t).

File attachments

@vicuna

This comment has been minimized.

Copy link
Author

commented May 25, 2012

Comment author: @garrigue

Duplicating the environment for GADT pattern matching resulted in wrong detection of self-escape.
Solved by not copying the argument to the dummy_method in subst.ml, under specific conditions.
Fixed in trunk and 4.00, at revisions 12482 and 12483.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.