diff src/elaborate.sml @ 2224:5709482a2afd

Merge.
author Ziv Scully <ziv@mit.edu>
date Thu, 11 Dec 2014 02:05:41 -0500
parents 834b438d57f3
children d4eb9b6729f8
line wrap: on
line diff
--- a/src/elaborate.sml	Sat Nov 29 04:34:41 2014 -0500
+++ b/src/elaborate.sml	Thu Dec 11 02:05:41 2014 -0500
@@ -3020,6 +3020,25 @@
 
       | (L'.SgnConst sgis1, L'.SgnConst sgis2) =>
         let
+            (* This reshuffling was added to avoid some unfortunate unification behavior.
+             * In particular, in sub-signature checking, constraints might be unified,
+             * even when we don't expect them to be unifiable, deciding on bad values
+             * for unification variables and dooming later unification.
+             * By putting all the constraints _last_, we allow all the other unifications
+             * to happen first, hoping that no unification variables survive to confuse
+             * constraint unification. *)
+
+            val sgis2 =
+                let
+                    val (constraints, others) = List.partition
+                                                   (fn (L'.SgiConstraint _, _) => true
+                                                   | _ => false) sgis2
+                in
+                    case constraints of
+                        [] => sgis2
+                      | _ => others @ constraints
+                end
+
             (*val () = prefaces "subSgn" [("sgn1", p_sgn env sgn1),
                                         ("sgn2", p_sgn env sgn2),
                                         ("sgis1", p_sgn env (L'.SgnConst sgis1, loc2)),