Skip to content

Commit 5953eb3

Browse files
jappeace-slothjappeace
authored andcommitted
Include provenance in Backpack unfilled requirements error
When a non-library component has unfilled Backpack signature requirements, the error message now shows where each requirement came from (e.g. "brought into scope by build-depends: Fail1") using the ModuleSource information already available in the ModuleScope. Updated the Fail3 test golden files and strengthened the test assertion to verify provenance information is present. Addresses #7192 run fourmalou
1 parent 131fb0d commit 5953eb3

11 files changed

Lines changed: 67 additions & 3 deletions

File tree

Cabal/src/Distribution/Backpack/LinkedComponent.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,17 @@ toLinkedComponent
258258
hang
259259
(text "Non-library component has unfilled requirements:")
260260
4
261-
(vcat [pretty req | req <- Set.toList reqs])
261+
( vcat
262+
[ case Map.lookup req (modScopeRequires linked_shape0) of
263+
Just srcs@(_ : _) ->
264+
hang
265+
(pretty req)
266+
4
267+
(vcat [text "brought into scope by" <+> dispModuleSource (getSource src) | src <- srcs])
268+
_ -> pretty req
269+
| req <- Set.toList reqs
270+
]
271+
)
262272

263273
-- NB: do NOT include hidden modules here: GHC 7.10's ghc-pkg
264274
-- won't allow it (since someone could directly synthesize
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Setup configure
22
Configuring Fail1-0.1.0.0...
33
Error:
4-
Non-library component has unfilled requirements: UnfilledSig
4+
Non-library component has unfilled requirements:
5+
UnfilledSig brought into scope by build-depends: Fail1
56
In the stanza executable foo
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Setup configure
22
Configuring Fail1-0.1.0.0...
33
Error:
4-
Non-library component has unfilled requirements: UnfilledSig
4+
Non-library component has unfilled requirements:
5+
UnfilledSig brought into scope by build-depends: Fail1
56
In the stanza executable foo

cabal-testsuite/PackageTests/Backpack/Fail3/setup.test.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ main = setupAndCabalTest $ do
33
skipUnlessGhcVersion ">= 8.1"
44
r <- fails $ setup' "configure" []
55
assertOutputContains "UnfilledSig" r
6+
assertOutputContains "brought into scope by" r
67
return ()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
cabal-version: 3.0
2+
name: Fail4
3+
version: 0.1.0.0
4+
license: BSD-3-Clause
5+
author: Edward Z. Yang
6+
maintainer: ezyang@cs.stanford.edu
7+
build-type: Simple
8+
9+
library sig-lib-a
10+
signatures: UnfilledSig
11+
build-depends: base
12+
hs-source-dirs: lib-a
13+
default-language: Haskell2010
14+
15+
library sig-lib-b
16+
signatures: UnfilledSig
17+
build-depends: base
18+
hs-source-dirs: lib-b
19+
default-language: Haskell2010
20+
21+
executable foo
22+
build-depends: Fail4:sig-lib-a, Fail4:sig-lib-b
23+
main-is: Main.hs
24+
default-language: Haskell2010
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
main = return ()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
signature UnfilledSig where
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
signature UnfilledSig where
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Setup configure
2+
Configuring Fail4-0.1.0.0...
3+
Error:
4+
Non-library component has unfilled requirements:
5+
UnfilledSig
6+
brought into scope by build-depends: Fail4:sig-lib-a
7+
brought into scope by build-depends: Fail4:sig-lib-b
8+
In the stanza executable foo
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Setup configure
2+
Configuring Fail4-0.1.0.0...
3+
Error:
4+
Non-library component has unfilled requirements:
5+
UnfilledSig
6+
brought into scope by build-depends: Fail4:sig-lib-a
7+
brought into scope by build-depends: Fail4:sig-lib-b
8+
In the stanza executable foo

0 commit comments

Comments
 (0)