Skip to content

Commit

Permalink
Prevent crash on unkown path for haskell parse errors
Browse files Browse the repository at this point in the history
The haskell parser returns '<unknown>.hs' if no path is explicitly given.
  • Loading branch information
anka-213 authored and jespercockx committed Sep 23, 2024
1 parent f5596af commit 79d3bbe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Agda2Hs/HsUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------------------------

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 79d3bbe

Please sign in to comment.