Skip to content

Commit

Permalink
Stop printing context after a definition.
Browse files Browse the repository at this point in the history
  • Loading branch information
noahyor committed Jun 15, 2024
1 parent 1ebe7fa commit 22c818e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/swarm-lang/Swarm/Language/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,22 @@ prettyTypeErr :: Text -> ContextualTypeErr -> Doc ann
prettyTypeErr code (CTE l tcStack te) =
vcat
[ teLoc <> ppr te
, ppr (BulletList "" tcStack)
, ppr (BulletList "" (filterTCStack tcStack))
]
where
teLoc = case l of
SrcLoc s e -> (showLoc . fst $ getLocRange code (s, e)) <> ": "
NoLoc -> emptyDoc
showLoc (r, c) = pretty r <> ":" <> pretty c

-- |
filterTCStack :: TCStack -> TCStack
filterTCStack tcStack = case tcStack of
[] -> []
t@(LocatedTCFrame src (TCDef var)) : _ -> [t]
t@(LocatedTCFrame src TCBindR) : xs -> t : filterTCStack xs
t@(LocatedTCFrame src TCBindL) : xs -> t : filterTCStack xs

instance PrettyPrec TypeErr where
prettyPrec _ = \case
UnificationErr ue -> ppr ue
Expand Down

0 comments on commit 22c818e

Please sign in to comment.