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

Internal typechecker error triggered by a constraint on self type in a class type #7711

vicuna opened this issue Jan 18, 2018 · 3 comments


Copy link

vicuna commented Jan 18, 2018

Original bug ID: 7711
Reporter: @Octachron
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2018-01-30T07:09:55Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.07.0+dev/beta2/rc1/rc2
Fixed in version: 4.07.0+dev/beta2/rc1/rc2
Category: typing
Monitored by: @nojb @gasche

Bug description

The following code fails (on ? — 4.02.3 — trunk) with a failed assertion in Ctype.object_fields:

type 'a r = <w: int -> int; .. > as 'a
class type virtual ct = object('self)
constraint 'self = 'not_self r

Note also that the snippet above compiles fine if 'not_self is replaced by 'self, if the type constructor r is inlined, or if ct is made a virtual class.

Copy link

vicuna commented Jan 23, 2018

Comment author: @garrigue

That's a bad one.
I think it's been there since the very beginning of ocaml:
functions all over the place seem to assume that the signature of a class is an object type, never an abbreviation, but nothing prevents from unifying it with an abbreviation.

I see no easy solution short of changing the type of csig_self to something safer.
The simplest change would be to use type_desc rather than type_expr.

Copy link

vicuna commented Jan 24, 2018

Comment author: @garrigue

Tentative fix: #1581

Not so clean as it adds cruft to unify3, but I see no other easy way.

Copy link

vicuna commented Jan 30, 2018

Comment author: @garrigue

Fixed by commit 54225b5 in trunk.

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

No branches or pull requests

2 participants