From 8020265e04b23aec08eb84a91bc817b4b21a1a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20von=20Sydow?= Date: Tue, 8 Oct 2024 19:30:50 +0200 Subject: [PATCH 1/2] Improved location determination for constraints --- compiler/Acton/Syntax.hs | 7 ++++++- compiler/Acton/TypeEnv.hs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/Acton/Syntax.hs b/compiler/Acton/Syntax.hs index e47d789f2..958c7ffab 100644 --- a/compiler/Acton/Syntax.hs +++ b/compiler/Acton/Syntax.hs @@ -587,7 +587,12 @@ instance HasLoc Type where loc = tloc instance HasLoc Constraint where - loc c = loc (info c) + loc (Cast info t1 t2) = getLoc [loc info, loc t1, loc t2] + loc (Sub info _ t1 t2) = getLoc [loc info, loc t1, loc t2] + loc (Impl info _ t1 _) = getLoc [loc info, loc t1] + loc (Sel info _ t1 n1 t2) = getLoc [loc info, loc t1, loc n1, loc t2] + loc (Mut info t1 n1 t2) = getLoc [loc info, loc t1, loc n1, loc t2] + loc (Seal info t1) = getLoc [loc info, loc t1] instance HasLoc ErrInfo where loc (Simple l _) = l diff --git a/compiler/Acton/TypeEnv.hs b/compiler/Acton/TypeEnv.hs index fffafcd7c..c7c421a19 100644 --- a/compiler/Acton/TypeEnv.hs +++ b/compiler/Acton/TypeEnv.hs @@ -146,7 +146,7 @@ instQuals env q ts = do let s = qbound q `zip` ts sequence [ constr (subst s (tVar v)) (subst s u) | Quant v us <- q, u <- us ] where constr t u@(TC n _) | isProto env n = do w <- newWitness; return $ Impl (DfltInfo NoLoc 24 Nothing []) w t u - | otherwise = return $ Cast (DfltInfo (loc t) 25 Nothing []) t (tCon u) + | otherwise = return $ Cast (DfltInfo NoLoc 25 Nothing []) t (tCon u) wvars :: Constraints -> [Expr] wvars cs = [ eVar v | Impl _ v _ _ <- cs ] From 0675b126a336f801b114e701080f9f59365a3126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20von=20Sydow?= Date: Tue, 8 Oct 2024 19:35:53 +0200 Subject: [PATCH 2/2] changed golden file for typeerror/ex24.act --- test/typeerrors/ex24.golden | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/typeerrors/ex24.golden b/test/typeerrors/ex24.golden index 26c6c161a..e00496a90 100644 --- a/test/typeerrors/ex24.golden +++ b/test/typeerrors/ex24.golden @@ -3,6 +3,10 @@ Building file ../test/typeerrors/ex24.act ERROR: Error when compiling ex24 module: Type error + | +4 | a : ?str = "" + | ^^^^^ ?__builtin__.str must implement __builtin__.Hashable + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -