Show the locations of the definitions when reporting invalid dependencies

We only show the file location as these will always be in the same file,
I think.
This commit is contained in:
Iavor Diatchki 2021-04-01 11:17:08 -07:00
parent 65cd467741
commit cb21ab61ba
5 changed files with 15 additions and 7 deletions

View File

@ -62,6 +62,12 @@ data DepName = NamedThing Name
| ConstratintAt Range -- ^ identifed by location in source
deriving (Eq,Ord,Show,Generic,NFData)
depNameLoc :: DepName -> Range
depNameLoc x =
case x of
NamedThing n -> nameLoc n
ConstratintAt r -> r
instance PP RenamerError where
@ -134,7 +140,9 @@ instance PP RenamerError where
InvalidDependency ds ->
"[error] Invalid recursive dependency:"
$$ nest 4 (vcat [ "" <+> pp x | x <- ds ])
$$ nest 4 (vcat [ "" <+> pp x <+> ", defined at" <+> ppR (depNameLoc x)
| x <- ds ])
where ppR r = pp (from r) <.> "--" <.> pp (to r)
instance PP DepName where
ppPrec _ d =

View File

@ -3,4 +3,4 @@ Loading module Cryptol
Loading module binarytree
[error] Invalid recursive dependency:
• type binarytree::Tree
• type binarytree::Tree , defined at 3:9--3:13

View File

@ -3,5 +3,5 @@ Loading module Cryptol
Loading module T3
[error] Invalid recursive dependency:
• T3::x
• submodule T3::A
• T3::x , defined at 4:1--4:2
• submodule T3::A , defined at 6:11--6:12

View File

@ -3,5 +3,5 @@ Loading module Cryptol
Loading module T9
[error] Invalid recursive dependency:
• T9::x
• submodule T9::A
• T9::x , defined at 3:1--3:2
• submodule T9::A , defined at 5:11--5:12

View File

@ -52,7 +52,7 @@ Loading module Cryptol
Loading module Main
[error] Invalid recursive dependency:
• type Main::T
• type Main::T , defined at 1:6--1:7
Loading module Cryptol
Loading module Main