ref: 40ab729e3177262d5f2ab88be5a2992e8bfb8e9d
parent: 1a00ebdde37999b0cca6bc8b9ab5a1e89ab7e90f
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Fri Oct 13 14:38:04 EDT 2023
More error tests
--- a/comb/mhs.comb
+++ b/comb/mhs.comb
@@ -1,3 +1,3 @@
v4.0
-979
-((A :0 _863) ((A :1 ((B _909) _0)) ((A :2 (((S' _909) _0) I)) ((A :3 _833) ((A :4 (_3 "undefined")) ((A :5 I) ((A :6 (((C' B) _862) ((C _74) _5))) ((A :7 (((C' _6) (_880 _71)) ((_74 _878) _70))) ((A :8 ((B ((S _909) _878)) _3)) ((A :9 T) ((A :10 (T I)) ((A :11 ((B (_74 _189)) _10)) ((A :12 ((B (B (_73 _9))) (((C' B) ((B C) _10)) (B _10)))) ((A :13 ((B (B (_73 _9))) (((C' B) ((B C) _10)) (BK _10)))) ((A :14 ((B (_73 _9)) P)) ((A :15 ((B (B (_73 _9))) ((B ((C' C) _10)) (B P)))) ((A :16 _15) ((A :17 ((B (_73 _9)) (B (P _791)))) ((A :18 ((B (_73 _9)) (BK (P _791)))) ((A :19 ((_73 _9) ((S P) I))) ((A :20 ((B (_73 _9)) ((C (S' P)) I))) ((A :21 ((B Y) ((B (B (P (_14 _114)))) (((C' B) ((B (C' B)) (B _12))) (((C' (C' B)) (B _12)) ((B (B _14)) _115)))))) ((A :22 ((B Y) ((B (B (P (_14 _791)))) ((B (C' B)) (B _13))))) ((A :23 _3) ((A :24 (T (_14 _791))) ((A :25 (_21 _75)) ((A :26 (R _33)) ((A :27 (T _32)) ((A :28 ((P _33) _32)) ((A :29 _33) ((A :30 ((C ((C S') _28)) I)) ((A :31 ((C S) _28)) ((A :32 K) ((A :33 A) ((A :34 _838) ((A :35 _839) ((A :36 (((S' _27) (_830 #97)) ((C _830) #122))) ((A :37 (((S' _27) (_830 #65)) ((C _830) #90))) ((A :38 (((S' _26) _36) _37)) ((A :39 (((S' _27) (_830 #48)) ((C _830) #57))) ((A :40 (((S' _27) (_830 #32)) ((C _830) #126))) ((A :41 _827) ((A :42 _828) ((A :43 _830) ((A :44 _829) ((A :45 (((S' _26) ((C _41) #32)) (((S' _26) ((C _41) #9)) ((C _41) #10)))) ((A :46 ((S ((S (((S' _27) (_43 #65)) ((C _43) #90))) (_33 (((_790 "lib/Data/Char.hs") #3) #8)))) ((B _34) (((C' _81) (((C' _82) _35) (_35 #65))) (_35 #97))))) ((A :47 ((S ((S (((S' _27) (_43 #97)) ((C _43) #97))) (_33 (((_790 "lib/Data/Char.hs") #3) #8)))) ((B _34) (((C' _81) (((C' _82) _35) (_35 #97))) (_35 #65))))) ((A :48 _798) ((A :49 _799) ((A :50 _800) ((A :51 _801) ((A :52 (_49 %0.0)) ((A :53 _48) ((A :54 _49) ((A :55 _50) ((A :56 _51) ((A :57 _802) ((A :58 _803) ((A :59 _57) ((A :60 _58) ((A :61 _804) ((A :62 _805) ((A :63 _806) ((A :64 _807) ((A :65 _61) ((A :66 _62) ((A :67 _63) ((A :68 _64) ((A :69 _808) ((A :70 ((B BK) T)) ((A :71 (BK T)) ((A :72 P) ((A :73 I) ((A :74 B) ((A :75 I) ((A :76 K) ((A :77 C) ((A :78 _834) ((A :79 ((C ((C S') _189)) _190)) ((A :80 (((C' (S' (C' B))) B) I)) ((A :81 _792) ((A :82 _793) ((A :83 _794) ((A :84 _795) ((A :85 _796) ((A :86 _797) ((A :87 (_82 #0)) ((A :88 _815) ((A :89 _816) ((A :90 _817) ((A :91 _818) ((A :92 _819) ((A :93 _820) ((A :94 _88) ((A :95 (BK K)) ((A :96 ((B BK) ((B (B BK)) P))) ((A :97 ((B (B (B BK))) ((B (B (B BK))) ((B (B (B C))) ((B (B C)) P))))) ((A :98 (((S' S) (((S' (S' C)) (((C' (C' S)) (((C' B) ((B (S' S')) (((C' B) ((B _26) (_91 #0))) (_88 #0)))) ((B (B ((C' P) (_86 #1)))) _81))) (C P))) _84)) _85)) ((A :99 _95) ((A :100 (((S' C) ((B (P _177)) (((C' (C' B)) (((C' C) _88) _177)) _178))) ((B ((C' (C' (C' C))) (((C' (C' (C' C))) (((C' (C' (C' (C' S')))) ((B (B (B (B C)))) ((B ((C' (C' (C' C))) ((B (B (B ((S' S') (_88 #0))))) ((B ((C' (C' C)) ((B (B ((S' S') (_88 #1)))) ((B ((C' C) ((B ((C' S') (_88 #2))) (C _100)))) (C _100))))) (C _100))))) (C _100)))) (T K))) (T A)))) ((C _98) #4)))) ((A :101 (_107 _76)) ((A :102 ((_122 (_79 _101)) _99)) ((A :103 ((C (((C' B) ((P _114) (((C' (C' O)) P) K))) (((S' (C' (C' (C' B)))) ((B (B (B (B _104)))) (((S' (C' (C' B))) ((B (B (B _104))) (((S' (C' B)) ((B (B _104)) (((C' B) ((B _120) (T #0))) _103))) (((C' B) ((B _120) (T #1))) _103)))) (((C' B) ((B _120) (T #2))) _103)))) (((C' B) ((B _120) (T #3))) _103)))) ((B T) ((B (B P)) ((C' _81) (_83 #4)))))) ((A :104 ((S S) ((B BK) ((B BK) (((S' S) T) ((B BK) ((B BK) ((C (((S' C') S) ((B (B (B (S B)))) ((B (B (B (B (B BK))))) ((B ((S' (C' B)) ((B B') B'))) ((B (B (B (B (B (S B)))))) ((B (B (B (B (B (B (B BK))))))) (((C' B) (B' (B' ((B (C' (C' (C' C)))) ((B ((C' B) (B' ((B C) _90)))) ((B ((C' B) _115)) _104)))))) ((B ((C' B) _115)) (C _104)))))))))) (((_790 "lib/Data/IntMap.hs") #3) #8))))))))) ((A :105 ((_74 (_120 _189)) _103)) ((A :106 (((C' C) (((C' C) (C _100)) (_3 "Data.IntMap.!"))) I)) ((A :107 ((B ((C' B) T)) ((B (B Y)) (((C' (C' (S' (S' C)))) ((B ((S' B) ((B (S' P)) (C _96)))) ((B (B ((C' (S' C
\ No newline at end of file
+980
+((A :0 _863) ((A :1 ((B _910) _0)) ((A :2 (((S' _910) _0) I)) ((A :3 _833) ((A :4 (_3 "undefined")) ((A :5 I) ((A :6 (((C' B) _862) ((C _74) _5))) ((A :7 (((C' _6) (_881 _71)) ((_74 _879) _70))) ((A :8 ((B ((S _910) _879)) _3)) ((A :9 T) ((A :10 (T I)) ((A :11 ((B (_74 _189)) _10)) ((A :12 ((B (B (_73 _9))) (((C' B) ((B C) _10)) (B _10)))) ((A :13 ((B (B (_73 _9))) (((C' B) ((B C) _10)) (BK _10)))) ((A :14 ((B (_73 _9)) P)) ((A :15 ((B (B (_73 _9))) ((B ((C' C) _10)) (B P)))) ((A :16 _15) ((A :17 ((B (_73 _9)) (B (P _791)))) ((A :18 ((B (_73 _9)) (BK (P _791)))) ((A :19 ((_73 _9) ((S P) I))) ((A :20 ((B (_73 _9)) ((C (S' P)) I))) ((A :21 ((B Y) ((B (B (P (_14 _114)))) (((C' B) ((B (C' B)) (B _12))) (((C' (C' B)) (B _12)) ((B (B _14)) _115)))))) ((A :22 ((B Y) ((B (B (P (_14 _791)))) ((B (C' B)) (B _13))))) ((A :23 _3) ((A :24 (T (_14 _791))) ((A :25 (_21 _75)) ((A :26 (R _33)) ((A :27 (T _32)) ((A :28 ((P _33) _32)) ((A :29 _33) ((A :30 ((C ((C S') _28)) I)) ((A :31 ((C S) _28)) ((A :32 K) ((A :33 A) ((A :34 _838) ((A :35 _839) ((A :36 (((S' _27) (_830 #97)) ((C _830) #122))) ((A :37 (((S' _27) (_830 #65)) ((C _830) #90))) ((A :38 (((S' _26) _36) _37)) ((A :39 (((S' _27) (_830 #48)) ((C _830) #57))) ((A :40 (((S' _27) (_830 #32)) ((C _830) #126))) ((A :41 _827) ((A :42 _828) ((A :43 _830) ((A :44 _829) ((A :45 (((S' _26) ((C _41) #32)) (((S' _26) ((C _41) #9)) ((C _41) #10)))) ((A :46 ((S ((S (((S' _27) (_43 #65)) ((C _43) #90))) (_33 (((_790 "lib/Data/Char.hs") #3) #8)))) ((B _34) (((C' _81) (((C' _82) _35) (_35 #65))) (_35 #97))))) ((A :47 ((S ((S (((S' _27) (_43 #97)) ((C _43) #97))) (_33 (((_790 "lib/Data/Char.hs") #3) #8)))) ((B _34) (((C' _81) (((C' _82) _35) (_35 #97))) (_35 #65))))) ((A :48 _798) ((A :49 _799) ((A :50 _800) ((A :51 _801) ((A :52 (_49 %0.0)) ((A :53 _48) ((A :54 _49) ((A :55 _50) ((A :56 _51) ((A :57 _802) ((A :58 _803) ((A :59 _57) ((A :60 _58) ((A :61 _804) ((A :62 _805) ((A :63 _806) ((A :64 _807) ((A :65 _61) ((A :66 _62) ((A :67 _63) ((A :68 _64) ((A :69 _808) ((A :70 ((B BK) T)) ((A :71 (BK T)) ((A :72 P) ((A :73 I) ((A :74 B) ((A :75 I) ((A :76 K) ((A :77 C) ((A :78 _834) ((A :79 ((C ((C S') _189)) _190)) ((A :80 (((C' (S' (C' B))) B) I)) ((A :81 _792) ((A :82 _793) ((A :83 _794) ((A :84 _795) ((A :85 _796) ((A :86 _797) ((A :87 (_82 #0)) ((A :88 _815) ((A :89 _816) ((A :90 _817) ((A :91 _818) ((A :92 _819) ((A :93 _820) ((A :94 _88) ((A :95 (BK K)) ((A :96 ((B BK) ((B (B BK)) P))) ((A :97 ((B (B (B BK))) ((B (B (B BK))) ((B (B (B C))) ((B (B C)) P))))) ((A :98 (((S' S) (((S' (S' C)) (((C' (C' S)) (((C' B) ((B (S' S')) (((C' B) ((B _26) (_91 #0))) (_88 #0)))) ((B (B ((C' P) (_86 #1)))) _81))) (C P))) _84)) _85)) ((A :99 _95) ((A :100 (((S' C) ((B (P _177)) (((C' (C' B)) (((C' C) _88) _177)) _178))) ((B ((C' (C' (C' C))) (((C' (C' (C' C))) (((C' (C' (C' (C' S')))) ((B (B (B (B C)))) ((B ((C' (C' (C' C))) ((B (B (B ((S' S') (_88 #0))))) ((B ((C' (C' C)) ((B (B ((S' S') (_88 #1)))) ((B ((C' C) ((B ((C' S') (_88 #2))) (C _100)))) (C _100))))) (C _100))))) (C _100)))) (T K))) (T A)))) ((C _98) #4)))) ((A :101 (_107 _76)) ((A :102 ((_122 (_79 _101)) _99)) ((A :103 ((C (((C' B) ((P _114) (((C' (C' O)) P) K))) (((S' (C' (C' (C' B)))) ((B (B (B (B _104)))) (((S' (C' (C' B))) ((B (B (B _104))) (((S' (C' B)) ((B (B _104)) (((C' B) ((B _120) (T #0))) _103))) (((C' B) ((B _120) (T #1))) _103)))) (((C' B) ((B _120) (T #2))) _103)))) (((C' B) ((B _120) (T #3))) _103)))) ((B T) ((B (B P)) ((C' _81) (_83 #4)))))) ((A :104 ((S S) ((B BK) ((B BK) (((S' S) T) ((B BK) ((B BK) ((C (((S' C') S) ((B (B (B (S B)))) ((B (B (B (B (B BK))))) ((B ((S' (C' B)) ((B B') B'))) ((B (B (B (B (B (S B)))))) ((B (B (B (B (B (B (B BK))))))) (((C' B) (B' (B' ((B (C' (C' (C' C)))) ((B ((C' B) (B' ((B C) _90)))) ((B ((C' B) _115)) _104)))))) ((B ((C' B) _115)) (C _104)))))))))) (((_790 "lib/Data/IntMap.hs") #3) #8))))))))) ((A :105 ((_74 (_120 _189)) _103)) ((A :106 (((C' C) (((C' C) (C _100)) (_3 "Data.IntMap.!"))) I)) ((A :107 ((B ((C' B) T)) ((B (B Y)) (((C' (C' (S' (S' C)))) ((B ((S' B) ((B (S' P)) (C _96)))) ((B (B ((C' (S' C
\ No newline at end of file
--- a/src/MicroHs/TypeCheck.hs
+++ b/src/MicroHs/TypeCheck.hs
@@ -132,7 +132,7 @@
expLookup i m =
case M.lookup i m of
Just [e] -> e
- Just _ -> errorMessage (getSLocIdent i) $ ": Ambiguous export " ++ showIdent i
+ Just _ -> errorMessage (getSLocIdent i) $ "ambiguous export " ++ showIdent i
Nothing -> expErr i
tyQIdent :: Entry -> Ident
@@ -158,11 +158,8 @@
eVarI :: SLoc -> String -> Expr
eVarI loc = EVar . mkIdentSLoc loc
---tcExpErr :: forall a . Ident -> T a
---tcExpErr i = tcError (getSLocIdent i) $ ": export undefined " ++ showIdent i
-
expErr :: forall a . Ident -> a
-expErr i = errorMessage (getSLocIdent i) $ ": export undefined " ++ showIdent i
+expErr i = errorMessage (getSLocIdent i) $ "export undefined " ++ showIdent i
mkTModule :: forall a . IdentModule -> [EDef] -> a -> TModule a
mkTModule mn tds a =
@@ -1122,7 +1119,7 @@
calc es oos@((oy, (ay, py)):os) iies@((oo@(ox, (ax, px)), e) : ies) =
-- traceM (show ((unIdent (getIdent (fst o)), ay, py), (unIdent i, ax, px)))
if px == py && (not (eqAssoc ax ay) || eqAssoc ax AssocNone) then
- errorMessage (getSLocExpr ox) "Ambiguous operator expression"
+ errorMessage (getSLocExpr ox) "ambiguous operator expression"
else if px < py || eqAssoc ax AssocLeft && px == py then
doOp es oy os iies
else
--- a/tests/errmsg.test
+++ b/tests/errmsg.test
@@ -1,22 +1,65 @@
+module E() where
+import Prelude
x = y
-----
-mhs: "../tmp/E.hs": line 3, col 1: undefined no type signature: x
+mhs: "../tmp/E.hs": line 4, col 1: undefined no type signature: x
+
=====
+module E() where
+import Prelude
x :: Int
x = y
-----
-mhs: "../tmp/E.hs": line 4, col 5: undefined variable: y
+mhs: "../tmp/E.hs": line 5, col 5: undefined variable: y
+
=====
+module E() where
+import Prelude
x :: T
x = 1
-----
-mhs: "../tmp/E.hs": line 3, col 6: undefined variable: T
+mhs: "../tmp/E.hs": line 4, col 6: undefined variable: T
+
=====
+module E() where
+import Prelude
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
+mhs: "../tmp/E.hs": line 6, col 8: bad synonym use
+
+=====
+module E(fmap) where
+import Prelude
+import Control.Monad.State.Strict
+-----
+mhs: "../tmp/E.hs": line 2, col 10: ambiguous export fmap
+
+=====
+module E(module M) where
+-----
+mhs: "../tmp/E.hs": line 2, col 17: export undefined M
+
+=====
+module E(M) where
+-----
+mhs: "../tmp/E.hs": line 2, col 10: export undefined M
+
+=====
+module E() where
+import Prelude
+infixl 5 +++
+infixr 5 ***
+(+++) :: Int -> Int -> Int
+(+++) = (+)
+(***) :: Int -> Int -> Int
+(***) = (*)
+x :: Int
+x = 1 +++ 2 *** 3
+-----
+mhs: "../tmp/E.hs": line 11, col 13: ambiguous operator expression
+
=====
END
--- a/tests/errtester.sh
+++ b/tests/errtester.sh
@@ -3,12 +3,12 @@
tmp=../tmp
out=$tmp/E.hs
err=$tmp/err
+terr=$tmp/terr
cerr=$tmp/cerr
comp=../bin/mhs
read -r line
while [ "$line" != "END" ]; do
- echo "module E(module E) where" > $out
- echo "import Prelude" >> $out
+ echo > $out
while true; do
if [ "$line" = "-----" ]; then
break
@@ -16,13 +16,13 @@
echo "$line" >> $out
read -r line
done
- cp /dev/null $err
+ echo > $terr
read -r line
while true; do
if [ "$line" = "=====" ]; then
break
fi
- echo "$line" >> $err
+ echo "$line" >> $terr
read -r line
done
read -r line
@@ -33,6 +33,7 @@
#cat $err
#echo "==="
#echo "next: $line"
+ sed -e '/^ *$/d' $terr > $err
$comp -i../lib -i../tmp E 2>&1 | sed -e '/CallStack/,$d' -e '/^XX/d' > $cerr
diff $err $cerr || exit 1
done
--
⑨