Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved location determination for constraints #1938

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/Acton/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/Acton/TypeEnv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down
4 changes: 4 additions & 0 deletions test/typeerrors/ex24.golden
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

Loading