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
I had a look this afternoon and I believe this is an old bug in Ctype.copy that was uncovered by the introduction of more calls to generalize_structure in type_cases (by d43ccfc ).
I'm guessing (but I don't really understand that part of the code) the issue is that in the Tvariant case, we're mutating more.desc, without necessarily having saved it before (e.g. when more.desc is Tnil and partial = Some _).
I'll let someone who knows that part look into the issue further.
Thomas' analysis is correct.
The introduction of the partial parameter in Ctype.copy created a wrong case where more was modified without being copied (since it was not generalized).
As to why it was not triggered before, I believe this is more related to the fact that partial copy is only invoked in type_cases, and this was limited to pattern-matches containing explicit GADT constructors, or polymorphic variants both in the pattern and in the argument type, which is not the case here. In 4.07, this is called always with in principal mode.
Sorry, the analysis of why the bug didn't occur before is wrong: the condition for partial_instance has not changed, just the place where it is computed.
On the other hand I do not see how the extra generalizations in type_cases could be related to that: they only occur after the copy.
Anyway, this original code was incorrect, and I believe this is just by chance that this was not triggered before.
Original bug ID: 7838
Reporter: @mmottl
Assigned to: @garrigue
Status: resolved (set by @trefis on 2018-08-29T10:01:58Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 4.07.0
Category: typing
Monitored by: @nojb @gasche @mmottl
Bug description
Consider the following code in file "foo.ml":
Executing "ocaml -principal foo.ml" will yield:
The problem will only appear with "-principal" and does not seem to exist in versions before OCaml 4.07.0.
The text was updated successfully, but these errors were encountered: