closes #9603
@@ -141,7 +141,10 @@ module Monomorph = struct
bind m t
end
| _ ->
- check_constraints m t;
+ (* Due to recursive constraints like in #9603, we tentatively bind the monomorph to the type we're checking
+ against before checking the constraints. *)
+ m.tm_type <- Some t;
+ Std.finally (fun () -> m.tm_type <- None) (fun () -> check_constraints m t) ();
do_bind m t
@@ -0,0 +1,17 @@
+package unit.issues;
+import unit.Test;
+
+function sort<T:{next:T}>(l:T) {}
+private class C {
+ public var next:C;
+ public function new() {}
+}
+class Issue9603 extends Test {
+ function test() {
+ sort(new C());
+ utest.Assert.pass();
+ }