Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
c7061392
by mangoiv at 2025-12-05T16:27:42-05:00
4 changed files:
- compiler/GHC/Unit/Module/Graph.hs
- + testsuite/tests/th/T26568.hs
- + testsuite/tests/th/T26568.stderr
- testsuite/tests/th/all.T
Changes:
| ... | ... | @@ -565,16 +565,26 @@ mgReachableLoop mg nk = map summaryNodeSummary modules_below where |
| 565 | 565 | allReachableMany td_map (mapMaybe lookup_node nk)
|
| 566 | 566 | |
| 567 | 567 | |
| 568 | --- | @'mgQueryZero' g root b@ answers the question: can we reach @b@ from @root@
|
|
| 568 | +-- | @'mgQueryZero' g root target@ answers the question: can we reach @target@ from @root@
|
|
| 569 | 569 | -- in the module graph @g@, only using normal (level 0) imports?
|
| 570 | +--
|
|
| 571 | +-- If the @target@ key is not reachable, there is no path.
|
|
| 572 | +-- The @root@ key not being in @g@ results in a panic.
|
|
| 570 | 573 | mgQueryZero :: ModuleGraph
|
| 571 | 574 | -> ZeroScopeKey
|
| 572 | 575 | -> ZeroScopeKey
|
| 573 | 576 | -> Bool
|
| 574 | -mgQueryZero mg nka nkb = isReachable td_map na nb where
|
|
| 577 | +mgQueryZero mg rootKey targetKey =
|
|
| 578 | + case lookup_node targetKey of
|
|
| 579 | + -- The module we are looking for may not be in the module graph at all,
|
|
| 580 | + -- e.g. if a reference to it did not arise from an explicit import
|
|
| 581 | + -- declaration (as in #26568).
|
|
| 582 | + Nothing -> False
|
|
| 583 | + Just ntarget -> isReachable td_map nroot ntarget
|
|
| 584 | + where
|
|
| 585 | + -- invariant: the root key has to exist in the graph
|
|
| 586 | + nroot = fromJust $ lookup_node rootKey
|
|
| 575 | 587 | (td_map, lookup_node) = mg_zero_graph mg
|
| 576 | - na = expectJust $ lookup_node nka
|
|
| 577 | - nb = expectJust $ lookup_node nkb
|
|
| 578 | 588 | |
| 579 | 589 | |
| 580 | 590 | -- | Reachability Query.
|
| 1 | +{-# LANGUAGE ExplicitLevelImports, TemplateHaskell, NoImplicitPrelude #-}
|
|
| 2 | +module T16568 where
|
|
| 3 | + |
|
| 4 | +x = $(do
|
|
| 5 | + _ <- _
|
|
| 6 | + _)
|
|
| 7 | + |
| 1 | +T26568.hs:5:3: error: [GHC-28914]
|
|
| 2 | + • Level error:
|
|
| 3 | + instance for ‘GHC.Internal.Base.Monad GHC.Internal.TH.Monad.Q’
|
|
| 4 | + is bound at levels {} but used at level -1
|
|
| 5 | + • In a stmt of a 'do' block: _ <- _
|
|
| 6 | + In the expression:
|
|
| 7 | + do _ <- _
|
|
| 8 | + _
|
|
| 9 | + In the untyped splice:
|
|
| 10 | + $(do _ <- _
|
|
| 11 | + _)
|
|
| 12 | + |
|
| 13 | +T26568.hs:5:8: error: [GHC-88464]
|
|
| 14 | + • Found hole: _ :: GHC.Internal.TH.Monad.Q a0
|
|
| 15 | + Where: ‘a0’ is an ambiguous type variable
|
|
| 16 | + • In a stmt of a 'do' block: _ <- _
|
|
| 17 | + In the expression:
|
|
| 18 | + do _ <- _
|
|
| 19 | + _
|
|
| 20 | + In the untyped splice:
|
|
| 21 | + $(do _ <- _
|
|
| 22 | + _)
|
|
| 23 | + |
|
| 24 | +T26568.hs:6:3: error: [GHC-88464]
|
|
| 25 | + • Found hole:
|
|
| 26 | + _ :: GHC.Internal.TH.Monad.Q GHC.Internal.TH.Syntax.Exp
|
|
| 27 | + • In a stmt of a 'do' block: _
|
|
| 28 | + In the expression:
|
|
| 29 | + do _ <- _
|
|
| 30 | + _
|
|
| 31 | + In the untyped splice:
|
|
| 32 | + $(do _ <- _
|
|
| 33 | + _)
|
|
| 34 | + |
| ... | ... | @@ -625,6 +625,7 @@ test('T25256', normal, compile_and_run, ['']) |
| 625 | 625 | test('T24572a', normal, compile, [''])
|
| 626 | 626 | test('T24572b', normal, compile_fail, [''])
|
| 627 | 627 | test('T24572c', normal, compile_fail, [''])
|
| 628 | +test('T26568', normal, compile_fail, [''])
|
|
| 628 | 629 | test('T24572d', normal, compile, [''])
|
| 629 | 630 | test('T25209', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
|
| 630 | 631 | test('TH_MultilineStrings', normal, compile_and_run, [''])
|