From 79d3bbe7bd7be884a783d37271b9bee3be95af94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=A4llberg?= Date: Sun, 22 Sep 2024 18:16:51 +0200 Subject: [PATCH] Prevent crash on unkown path for haskell parse errors The haskell parser returns '.hs' if no path is explicitly given. --- src/Agda2Hs/HsUtils.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Agda2Hs/HsUtils.hs b/src/Agda2Hs/HsUtils.hs index e7665486..e09a5a8b 100644 --- a/src/Agda2Hs/HsUtils.hs +++ b/src/Agda2Hs/HsUtils.hs @@ -17,6 +17,8 @@ import Agda.Syntax.Position import Agda.Utils.FileName ( mkAbsolute ) import Agda.Utils.List ( initLast ) import Agda.Utils.Maybe.Strict ( toStrict ) +import System.FilePath (isAbsolute) +import Agda.Utils.Maybe (boolToMaybe) -- Names ------------------------------------------------------------------ @@ -199,7 +201,7 @@ cloc (ConName l _) = l srcSpanToRange :: SrcSpan -> Range srcSpanToRange (SrcSpan file l1 c1 l2 c2) = - intervalToRange (toStrict $ Just $ mkRangeFile (mkAbsolute file) Nothing) $ Interval (pos l1 c1) (pos l2 c2) + intervalToRange (toStrict $ boolToMaybe (isAbsolute file) $ mkRangeFile (mkAbsolute file) Nothing) $ Interval (pos l1 c1) (pos l2 c2) where pos l c = Pn () 0 (fromIntegral l) (fromIntegral c) srcLocToRange :: SrcLoc -> Range