Catch-all aliases working again
[hcoop/domtool2.git] / src / describe.sml
index a39faeb..a753ddb 100644 (file)
@@ -100,7 +100,21 @@ fun describe_unification_error t ue =
            (print "Reason: Occurs check failed for ";
             print name;
             print " in:\n";
-            printd (p_typ t))
+            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
@@ -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) =>
-       (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) =>