[MLton-commit] r4155

Stephen Weeks MLton@mlton.org
Fri, 4 Nov 2005 13:58:01 -0800


Avoid spurious error due to unbound type variable in a type definition
in a signature.


----------------------------------------------------------------------

U   mlton/trunk/mlton/elaborate/elaborate-sigexp.fun

----------------------------------------------------------------------

Modified: mlton/trunk/mlton/elaborate/elaborate-sigexp.fun
===================================================================
--- mlton/trunk/mlton/elaborate/elaborate-sigexp.fun	2005-11-04 21:19:52 UTC (rev 4154)
+++ mlton/trunk/mlton/elaborate/elaborate-sigexp.fun	2005-11-04 21:57:59 UTC (rev 4155)
@@ -121,24 +121,33 @@
          Vector.keepAll
          (tyvars', fn a =>
           not (Vector.exists (tyvars, fn a' => Tyvar.sameName (a, a'))))
-      val _ =
-         if 0 = Vector.length unbound
-            then ()
+      val ty =
+         if 0 = Vector.length unbound then
+            ty
          else
             let
                open Layout
+               val () =
+                  Control.error (Tyvar.region (Vector.sub (tyvars', 0)),
+                                 seq [str (concat ["undefined type variable",
+                                                   if Vector.length unbound > 1
+                                                      then "s"
+                                                   else "",
+                                                      ": "]),
+                                      seq (separate
+                                           (Vector.toListMap (unbound,
+                                                              Tyvar.layout),
+                                            ", "))],
+                                 empty)
+               fun var a =
+                  if Vector.exists (unbound, fn a' => Tyvar.equals (a, a')) then
+                     Type.bogus
+                  else
+                     Type.var a
             in
-               Control.error (Tyvar.region (Vector.sub (tyvars', 0)),
-                              seq [str (concat ["undefined type variable",
-                                                if Vector.length unbound > 1
-                                                   then "s"
-                                                else "",
-                                                ": "]),
-                                   seq (separate
-                                        (Vector.toListMap (unbound,
-                                                           Tyvar.layout),
-                                         ", "))],
-                              empty)
+               Type.hom (ty, {con = Type.con,
+                              record = Type.record,
+                              var = var})
             end
       (* Need to get the representatives that were chosen when elaborating the
        * type.