shithub: MicroHs

Download patch

ref: bb93f5767e448d9bddf1d25418261e20e6fc0019
parent: 94643fd95f33844f874c80b7ca0b71bf7181913d
author: Lennart Augustsson <lennart@augustsson.net>
date: Fri Oct 13 09:38:52 EDT 2023

Better error message.

--- a/src/MicroHs/TypeCheck.hs
+++ b/src/MicroHs/TypeCheck.hs
@@ -441,7 +441,8 @@
           case M.lookup i syns of
             Nothing -> T.return $ foldl tApp t ts
             Just (EForall vks tt) ->
-              if length vks /= length ts then tcError (getSLocIdent i) $ ": bad synonym use: " --X ++ show (i, vks, ts)
+              if length vks /= length ts then tcError (getSLocIdent i) $ "bad synonym use"
+                                                                         --X ++ "\nXX " ++ show (i, vks, ts)
               else expandSyn $ subst (zip (map idKindIdent vks) ts) tt
             Just _ -> impossible
         EUVar _ -> T.return $ foldl tApp t ts
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,7 +1,9 @@
 MHS=../bin/mhs -i../lib
 EVAL=../bin/mhseval
-.PHONY: test time clean
+.PHONY: test time clean errtest alltest
 
+alltest:	test errtest
+
 test:
 	$(MHS) IOTest && (echo q | $(EVAL) a bb ccc | sed 's/^.ms/1ms/' > IOTest.out) && diff IOTest.ref IOTest.out
 	$(MHS) StringTest && $(EVAL) > StringTest.out && diff StringTest.ref StringTest.out
@@ -22,6 +24,8 @@
 	$(MHS) Catch      && $(EVAL) > Catch.out      && diff Catch.ref Catch.out
 	$(MHS) FArith     && $(EVAL) > FArith.out     && diff FArith.ref FArith.out
 	$(MHS) Infix      && $(EVAL) > Infix.out      && diff Infix.ref Infix.out
+
+errtest:
 	sh errtester.sh < errmsg.test
 
 time:
--- a/tests/errmsg.test
+++ b/tests/errmsg.test
@@ -12,4 +12,11 @@
 -----
 mhs: "../tmp/E.hs": line 3, col 6: undefined variable: T
 =====
+type T a = [a]
+data D (f :: Type -> Type) = D (f Int)
+x :: D T
+x = [0]
+-----
+mhs: "../tmp/E.hs": line 5, col 8: bad synonym use
+=====
 END
--- a/tests/errtester.sh
+++ b/tests/errtester.sh
@@ -33,6 +33,6 @@
     #cat $err
     #echo "==="
     #echo "next: $line"
-    $comp -i../lib -i../tmp E 2>&1 | sed -e '/CallStack/,$d' > $cerr
+    $comp -i../lib -i../tmp E 2>&1 | sed -e '/CallStack/,$d' -e '/^XX/d' > $cerr
     diff $err $cerr || exit 1
 done
--