Special error message for withholding arguments to configuration functions
authorAdam Chlipala <adamc@hcoop.net>
Sat, 26 May 2007 17:24:58 +0000 (17:24 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sat, 26 May 2007 17:24:58 +0000 (17:24 +0000)
src/describe.sml

index 1384d3b..a753ddb 100644 (file)
@@ -102,6 +102,20 @@ fun describe_unification_error t ue =
             print " in:\n";
             output (p_typ t))
 
             print " in:\n";
             output (p_typ t))
 
+fun will_be_action (t, _) =
+    case t of
+       TArrow (_, t') => will_be_action t'
+      | TAction _ => true
+      | TNested _ => true
+      | TUnif (_, ref (SOME t')) => will_be_action t'
+      | _ => false
+
+fun get_first_arg (t, _) =
+    case t of
+       TArrow (t', _) => t'
+      | TUnif (_, ref (SOME t')) => get_first_arg t'
+      | _ => raise Fail "get_first_arg failed!"
+
 fun describe_type_error loc te =
     case te of
        WrongType (place, e, t1, t2, ueo) =>
 fun describe_type_error loc te =
     case te of
        WrongType (place, e, t1, t2, ueo) =>
@@ -111,10 +125,15 @@ fun describe_type_error loc te =
         preface ("Needed type:", p_typ t2);
         Option.app (describe_unification_error t1) ueo)
       |        WrongForm (place, form, e, t, ueo) =>
         preface ("Needed type:", p_typ t2);
         Option.app (describe_unification_error t1) ueo)
       |        WrongForm (place, form, e, t, ueo) =>
-       (ErrorMsg.error (SOME loc) (place ^ " has a non-" ^ form ^ " type.");
-        preface ("Expression:", p_exp e);
-        preface ("      Type:", p_typ t);
-        Option.app (describe_unification_error t) ueo)
+       if form = "action" andalso will_be_action t then
+           (ErrorMsg.error (SOME loc) "Not enough arguments passed to configuration function.";
+            preface (" Expression so far:", p_exp e);
+            preface ("Next argument type:", p_typ (get_first_arg t)))
+       else
+           (ErrorMsg.error (SOME loc) (place ^ " has a non-" ^ form ^ " type.");
+            preface ("Expression:", p_exp e);
+            preface ("      Type:", p_typ t);
+            Option.app (describe_unification_error t) ueo)
       | UnboundVariable name =>
        ErrorMsg.error (SOME loc) ("Unbound variable " ^ name ^ ".\n")
       |        WrongPred (place, p1, p2) =>
       | UnboundVariable name =>
        ErrorMsg.error (SOME loc) ("Unbound variable " ^ name ^ ".\n")
       |        WrongPred (place, p1, p2) =>