# HG changeset patch # User Adam Chlipala # Date 1318689090 14400 # Node ID f6c74b4bc4e618d8ca18372ff5eeb6967857fec1 # Parent 287604b4a08dcac3ba525c467337b069cf5ba096 Change error message display order: only show disjointness/type class failures if all record unifications succeeded diff -r 287604b4a08d -r f6c74b4bc4e6 src/elaborate.sml --- a/src/elaborate.sml Sat Oct 15 10:19:50 2011 -0400 +++ b/src/elaborate.sml Sat Oct 15 10:31:30 2011 -0400 @@ -4335,6 +4335,8 @@ unifySummaries env (loc, k, normalizeRecordSummary env s1, normalizeRecordSummary env s2)) delayed end + + val checkConstraintErrors = ref (fn () => ()) in oneSummaryRound (); @@ -4404,42 +4406,36 @@ ([], _) => () | (_, true) => (oneSummaryRound (); solver gs) | _ => - app (fn Disjoint (loc, env, denv, c1, c2) => - let - val c1' = ElabOps.hnormCon env c1 - val c2' = ElabOps.hnormCon env c2 - - fun isUnif (c, _) = - case c of - L'.CUnif _ => true - | _ => false - - fun maybeAttr (c, _) = - case c of - L'.CRecord ((L'.KType, _), xts) => true - | _ => false - in - ErrorMsg.errorAt loc "Couldn't prove field name disjointness"; - eprefaces' [("Con 1", p_con env c1), - ("Con 2", p_con env c2), - ("Hnormed 1", p_con env c1'), - ("Hnormed 2", p_con env c2')]; - - (*app (fn (loc, env, k, s1, s2) => - eprefaces' [("s1", p_summary env (normalizeRecordSummary env s1)), - ("s2", p_summary env (normalizeRecordSummary env s2))]) - (!delayedUnifs);*) - - if (isUnif c1' andalso maybeAttr c2') - orelse (isUnif c2' andalso maybeAttr c1') then - TextIO.output (TextIO.stdErr, - "You may be using a disallowed attribute with an HTML tag.\n") - else - () - end - | TypeClass (env, c, r, loc) => - expError env (Unresolvable (loc, c))) - gs + checkConstraintErrors := + (fn () => app (fn Disjoint (loc, env, denv, c1, c2) => + let + val c1' = ElabOps.hnormCon env c1 + val c2' = ElabOps.hnormCon env c2 + + fun isUnif (c, _) = + case c of + L'.CUnif _ => true + | _ => false + + fun maybeAttr (c, _) = + case c of + L'.CRecord ((L'.KType, _), xts) => true + | _ => false + in + ErrorMsg.errorAt loc "Couldn't prove field name disjointness"; + eprefaces' [("Con 1", p_con env c1), + ("Con 2", p_con env c2), + ("Hnormed 1", p_con env c1'), + ("Hnormed 2", p_con env c2')] + + (*app (fn (loc, env, k, s1, s2) => + eprefaces' [("s1", p_summary env (normalizeRecordSummary env s1)), + ("s2", p_summary env (normalizeRecordSummary env s2))]) + (!delayedUnifs);*) + end + | TypeClass (env, c, r, loc) => + expError env (Unresolvable (loc, c))) + gs) end in solver gs @@ -4483,6 +4479,11 @@ | SOME p => expError env (Inexhaustive (loc, p))) (!delayedExhaustives); + if ErrorMsg.anyErrors () then + () + else + !checkConstraintErrors (); + (*preface ("file", p_file env' file);*) if !dumpTypes then diff -r 287604b4a08d -r f6c74b4bc4e6 tests/nopoly.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/nopoly.ur Sat Oct 15 10:31:30 2011 -0400 @@ -0,0 +1,2 @@ +fun x y = y.Hellodsad +val bar = x {Hello = 1, RightO = 2}