# HG changeset patch # User Adam Chlipala # Date 1417742559 18000 # Node ID 3d22f761a4b7db2d65a2e94639451c5bc33019d0 # Parent fd6d362666c01f6b38bad9b9b4a5e3515161d5a2 In checking signature subsumption, be sure to try constraints last. diff -r fd6d362666c0 -r 3d22f761a4b7 src/elab_env.sml --- a/src/elab_env.sml Thu Dec 04 19:54:04 2014 -0500 +++ b/src/elab_env.sml Thu Dec 04 20:22:39 2014 -0500 @@ -1114,7 +1114,24 @@ case sgn of SgnError => all | SgnVar n => hnormSgn env (#2 (lookupSgnNamed env n)) - | SgnConst _ => all + | SgnConst sgis => + 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 (constraint, others) = List.partition + (fn (SgiConstraint _, _) => true + | _ => false) sgis + in + case constraint of + [] => all + | _ => (SgnConst (others @ constraint), loc) + end | SgnFun _ => all | SgnProj (m, ms, x) => let