You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5562 Reporter:@alainfrisch Assigned to:@garrigue Status: closed (set by @xavierleroy on 2015-12-11T18:04:25Z) Resolution: not fixable Priority: normal Severity: minor Category: typing Monitored by:@jmeber
Bug description
The attached file takes 12s to compile with "ocamlc.opt -principal" and no measurable time without -principal.
All the time is spent in the unification, which keeps instantiating types. I've the feeling this is related to abbreviations. If we replace !Clflags.principal by false in Ctype.proper_abbrevs, then type-checking is immediate again.
This is a well-known problem with -principal and mutually recursive classes.
Basically, abbreviations ensure that recursive types expand to regular trees.
However, in the case of recursive classes, this means moving from a graph to a regular tree, which is exponential.
The problem is avoided by always expanding the same type constructor to the node when there are no type parameters.
This is fine in the normal mode, but incorrect in principal mode, since it means that sharing is increased, while principality detection relies on unsharing.
This is the main reason -principal is not enabled by default.
Sorry to see that you hit this bad case.
Note also that it is known that the situation is made worse by using module aliases.
Original bug ID: 5562
Reporter: @alainfrisch
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:04:25Z)
Resolution: not fixable
Priority: normal
Severity: minor
Category: typing
Monitored by: @jmeber
Bug description
The attached file takes 12s to compile with "ocamlc.opt -principal" and no measurable time without -principal.
File attachments
The text was updated successfully, but these errors were encountered: