Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
b18c8dd5
by Zubin Duggal at 2026-08-06T15:51:01-04:00
-
f839d0fb
by Zubin Duggal at 2026-08-06T15:51:01-04:00
6 changed files:
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Iface/Ext/Types.hs
- testsuite/tests/hiefile/should_compile/T24493.stderr
- + testsuite/tests/hiefile/should_run/T25709.hs
- + testsuite/tests/hiefile/should_run/T25709.stdout
- testsuite/tests/hiefile/should_run/all.T
Changes:
| ... | ... | @@ -92,7 +92,7 @@ import GHC.Iface.Make |
| 92 | 92 | import GHC.Iface.Recomp
|
| 93 | 93 | import GHC.Iface.Tidy
|
| 94 | 94 | import GHC.Iface.Ext.Ast ( mkHieFile )
|
| 95 | -import GHC.Iface.Ext.Types ( getAsts, hie_asts, hie_module )
|
|
| 95 | +import GHC.Iface.Ext.Types ( getAsts, hie_asts, hie_module, hie_types )
|
|
| 96 | 96 | import GHC.Iface.Ext.Binary ( readHieFile, writeHieFile , hie_file_result)
|
| 97 | 97 | import GHC.Iface.Ext.Debug ( diffFile, validateScopes )
|
| 98 | 98 | |
| ... | ... | @@ -167,7 +167,7 @@ import GHC.Data.StringBuffer |
| 167 | 167 | import GHC.Data.Maybe
|
| 168 | 168 | import qualified GHC.Data.Strict as Strict
|
| 169 | 169 | |
| 170 | - |
|
| 170 | +import qualified Data.Array as A
|
|
| 171 | 171 | import Data.List ( nub, isPrefixOf, partition )
|
| 172 | 172 | import qualified Data.List.NonEmpty as NE
|
| 173 | 173 | import Control.Monad
|
| ... | ... | @@ -332,7 +332,10 @@ extract_renamed_stuff mod_summary tc_result = do |
| 332 | 332 | hieFile <- mkHieFile mod_summary tc_result (fromJust rn_info)
|
| 333 | 333 | let out_file = ml_hie_file $ ms_location mod_summary
|
| 334 | 334 | liftIO $ writeHieFile out_file hieFile
|
| 335 | - liftIO $ putDumpFileMaybe logger Opt_D_dump_hie "HIE AST" FormatHaskell (ppr $ hie_asts hieFile)
|
|
| 335 | + let hie_doc =
|
|
| 336 | + ppr (hie_asts hieFile)
|
|
| 337 | + $+$ ppr (A.assocs $ hie_types hieFile)
|
|
| 338 | + liftIO $ putDumpFileMaybe logger Opt_D_dump_hie "HIE AST" FormatHaskell hie_doc
|
|
| 336 | 339 | |
| 337 | 340 | -- Validate HIE files
|
| 338 | 341 | when (gopt Opt_ValidateHie dflags) $ do
|
| ... | ... | @@ -159,6 +159,18 @@ data HieType a |
| 159 | 159 | | HCoercionTy
|
| 160 | 160 | deriving (Functor, Foldable, Traversable, Eq)
|
| 161 | 161 | |
| 162 | +instance Outputable a => Outputable (HieType a) where
|
|
| 163 | + ppr (HTyVarTy name) = ppr name
|
|
| 164 | + ppr (HAppTy fun arg) = parens $ ppr fun <+> ppr arg
|
|
| 165 | + ppr (HTyConApp tc args) = parens $ ppr tc <+> ppr args
|
|
| 166 | + ppr (HForAllTy ((name, ty), flag) body) =
|
|
| 167 | + text "forall" <+> ppr flag <+> ppr name O.<> text ":" <+> ppr ty O.<> text "." <+> ppr body
|
|
| 168 | + ppr (HFunTy mult arg res) = parens $ ppr arg <+> arrow <+> ppr res <+> ppr mult
|
|
| 169 | + ppr (HQualTy ctxt ty) = parens $ ppr ctxt <+> text "=>" <+> ppr ty
|
|
| 170 | + ppr (HLitTy lit) = ppr lit
|
|
| 171 | + ppr (HCastTy ty) = text "cast" <+> ppr ty
|
|
| 172 | + ppr HCoercionTy = text "<coercion>"
|
|
| 173 | + |
|
| 162 | 174 | type HieTypeFlat = HieType TypeIndex
|
| 163 | 175 | |
| 164 | 176 | -- | Roughly isomorphic to the original core 'Type'.
|
| ... | ... | @@ -222,6 +234,10 @@ instance Binary (HieArgs TypeIndex) where |
| 222 | 234 | put_ bh (HieArgs xs) = put_ bh xs
|
| 223 | 235 | get bh = HieArgs <$> get bh
|
| 224 | 236 | |
| 237 | +instance Outputable a => Outputable (HieArgs a) where
|
|
| 238 | + ppr (HieArgs args) = braces $ hsep $ punctuate comma $ map pprArg args
|
|
| 239 | + where pprArg (vis, ty) = (if vis then id else parens) (ppr ty)
|
|
| 240 | + |
|
| 225 | 241 | |
| 226 | 242 | -- A HiePath is just a lexical FastString. We use a lexical FastString to avoid
|
| 227 | 243 | -- non-determinism when printing or storing HieASTs which are sorted by their
|
| 1 | + |
|
| 1 | 2 | ==================== HIE AST ====================
|
| 2 | 3 | File: T24493.hs
|
| 3 | 4 | Node@T24493.hs:(1,8)-(3,8): Source: From source
|
| ... | ... | @@ -25,9 +26,10 @@ Node@T24493.hs:(1,8)-(3,8): Source: From source |
| 25 | 26 | Node@T24493.hs:3:6-8: Source: From source
|
| 26 | 27 | {(annotations: {(HsLit, HsExpr)}), (types: [0]),
|
| 27 | 28 | (identifier info: {})}
|
| 28 | -
|
|
| 29 | +
|
|
| 29 | 30 | |
| 31 | +[(0, (GHC.Internal.Base.String {}))]
|
|
| 30 | 32 | |
| 31 | 33 | |
| 32 | 34 | Got valid scopes
|
| 33 | -Got no roundtrip errors |
|
| \ No newline at end of file | ||
| 35 | +Got no roundtrip errors |
| 1 | +{-# LANGUAGE QuantifiedConstraints#-}
|
|
| 2 | +{-# LANGUAGE UndecidableInstances #-}
|
|
| 3 | +{-# LANGUAGE AllowAmbiguousTypes #-}
|
|
| 4 | +module Main where
|
|
| 5 | + |
|
| 6 | +import TestUtils
|
|
| 7 | +import qualified Data.Map.Strict as M
|
|
| 8 | +import qualified Data.Set as S
|
|
| 9 | +import Data.Either
|
|
| 10 | +import Data.Maybe
|
|
| 11 | +import Data.Bifunctor (first)
|
|
| 12 | +import GHC.Plugins (moduleNameString, nameStableString, nameOccName, occNameString, isDerivedOccName)
|
|
| 13 | +import GHC.Iface.Ext.Types
|
|
| 14 | + |
|
| 15 | + |
|
| 16 | +import Data.Typeable
|
|
| 17 | + |
|
| 18 | +data Some c where
|
|
| 19 | + Some :: c a => a -> Some c
|
|
| 20 | + |
|
| 21 | +extractSome :: (Typeable a, forall x. c x => Typeable x) => Some c -> Maybe a
|
|
| 22 | +extractSome (Some a) = cast a
|
|
| 23 | + |
|
| 24 | +f :: (forall x. Ord x => Eq [x]) => ()
|
|
| 25 | +f = ()
|
|
| 26 | +{-# NOINLINE f #-}
|
|
| 27 | + |
|
| 28 | +g :: ()
|
|
| 29 | +g = f
|
|
| 30 | + |
|
| 31 | +useQC :: forall c a. (c a, forall x. c x => Show x) => a -> String
|
|
| 32 | +useQC x = show x
|
|
| 33 | + |
|
| 34 | +points :: [(Int,Int)]
|
|
| 35 | +points = [(22,26),(29, 5), (32, 13)]
|
|
| 36 | + |
|
| 37 | +main = do
|
|
| 38 | + (df, hf) <- readTestHie "T25709.hie"
|
|
| 39 | + let refmap = generateReferencesMap $ getAsts $ hie_asts hf
|
|
| 40 | + traverse (explainEv df hf refmap) points |
| 1 | +==========================
|
|
| 2 | +At point (22,26), we found:
|
|
| 3 | +==========================
|
|
| 4 | +┌
|
|
| 5 | +│ $dTypeable at T25709.hs:22:14-19, of type: Typeable a
|
|
| 6 | +│ is an evidence variable bound by a let, depending on: [$dTypeable]
|
|
| 7 | +│ with scope: LocalScope T25709.hs:22:14-29
|
|
| 8 | +│
|
|
| 9 | +│ Defined at <no location info>
|
|
| 10 | +└
|
|
| 11 | +|
|
|
| 12 | +`- ┌
|
|
| 13 | + │ $dTypeable at T25709.hs:22:1-29, of type: Typeable a
|
|
| 14 | + │ is an evidence variable bound by a HsWrapper
|
|
| 15 | + │ with scope: LocalScope T25709.hs:22:1-29
|
|
| 16 | + │ bound at: T25709.hs:22:1-29
|
|
| 17 | + │ Defined at <no location info>
|
|
| 18 | + └
|
|
| 19 | + |
|
| 20 | +┌
|
|
| 21 | +│ $dTypeable at T25709.hs:22:14-19, of type: Typeable a
|
|
| 22 | +│ is an evidence variable bound by a let, depending on: [df, irred]
|
|
| 23 | +│ with scope: LocalScope T25709.hs:22:14-29
|
|
| 24 | +│
|
|
| 25 | +│ Defined at <no location info>
|
|
| 26 | +└
|
|
| 27 | +|
|
|
| 28 | ++- ┌
|
|
| 29 | +| │ df at T25709.hs:22:1-29, of type: forall x. c x => Typeable x
|
|
| 30 | +| │ is an evidence variable bound by a HsWrapper
|
|
| 31 | +| │ with scope: LocalScope T25709.hs:22:1-29
|
|
| 32 | +| │ bound at: T25709.hs:22:1-29
|
|
| 33 | +| │ Defined at <no location info>
|
|
| 34 | +| └
|
|
| 35 | +|
|
|
| 36 | +`- ┌
|
|
| 37 | + │ irred at T25709.hs:22:14-19, of type: c a
|
|
| 38 | + │ is an evidence variable bound by a let, depending on: [irred]
|
|
| 39 | + │ with scope: LocalScope T25709.hs:22:14-29
|
|
| 40 | + │
|
|
| 41 | + │ Defined at <no location info>
|
|
| 42 | + └
|
|
| 43 | + |
|
|
| 44 | + `- ┌
|
|
| 45 | + │ irred at T25709.hs:22:14-19, of type: c a
|
|
| 46 | + │ is an evidence variable bound by a pattern
|
|
| 47 | + │ with scope: LocalScope T25709.hs:22:14-29
|
|
| 48 | + │
|
|
| 49 | + │ Defined at <no location info>
|
|
| 50 | + └
|
|
| 51 | + |
|
| 52 | +==========================
|
|
| 53 | +At point (29,5), we found:
|
|
| 54 | +==========================
|
|
| 55 | +┌
|
|
| 56 | +│ df at T25709.hs:1:1, of type: forall x. Ord x => Eq [x]
|
|
| 57 | +│ is an evidence variable bound by a let, depending on: [$p1Ord,
|
|
| 58 | +│ $fEqList]
|
|
| 59 | +│ with scope: ModuleScope
|
|
| 60 | +│
|
|
| 61 | +│ Defined at <no location info>
|
|
| 62 | +└
|
|
| 63 | +|
|
|
| 64 | ++- ┌
|
|
| 65 | +| │ $p1Ord at T25709.hs:1:1, of type: forall a. Ord a => Eq a
|
|
| 66 | +| │ is a usage of an external evidence variable
|
|
| 67 | +| │ Defined in `GHC.Internal.Classes'
|
|
| 68 | +| └
|
|
| 69 | +|
|
|
| 70 | +`- ┌
|
|
| 71 | + │ $fEqList at T25709.hs:1:1, of type: forall a. Eq a => Eq [a]
|
|
| 72 | + │ is a usage of an external evidence variable
|
|
| 73 | + │ Defined in `GHC.Internal.Classes'
|
|
| 74 | + └
|
|
| 75 | + |
|
| 76 | +==========================
|
|
| 77 | +At point (32,13), we found:
|
|
| 78 | +==========================
|
|
| 79 | +┌
|
|
| 80 | +│ $dShow at T25709.hs:32:1-16, of type: Show a
|
|
| 81 | +│ is an evidence variable bound by a let, depending on: [df, irred]
|
|
| 82 | +│ with scope: LocalScope T25709.hs:32:1-16
|
|
| 83 | +│ bound at: T25709.hs:32:1-16
|
|
| 84 | +│ Defined at <no location info>
|
|
| 85 | +└
|
|
| 86 | +|
|
|
| 87 | ++- ┌
|
|
| 88 | +| │ df at T25709.hs:32:1-16, of type: forall x. c x => Show x
|
|
| 89 | +| │ is an evidence variable bound by a HsWrapper
|
|
| 90 | +| │ with scope: LocalScope T25709.hs:32:1-16
|
|
| 91 | +| │ bound at: T25709.hs:32:1-16
|
|
| 92 | +| │ Defined at <no location info>
|
|
| 93 | +| └
|
|
| 94 | +|
|
|
| 95 | +`- ┌
|
|
| 96 | + │ irred at T25709.hs:32:1-16, of type: c a
|
|
| 97 | + │ is an evidence variable bound by a let, depending on: [irred]
|
|
| 98 | + │ with scope: LocalScope T25709.hs:32:1-16
|
|
| 99 | + │ bound at: T25709.hs:32:1-16
|
|
| 100 | + │ Defined at <no location info>
|
|
| 101 | + └
|
|
| 102 | + |
|
|
| 103 | + `- ┌
|
|
| 104 | + │ irred at T25709.hs:32:1-16, of type: c a
|
|
| 105 | + │ is an evidence variable bound by a HsWrapper
|
|
| 106 | + │ with scope: LocalScope T25709.hs:32:1-16
|
|
| 107 | + │ bound at: T25709.hs:32:1-16
|
|
| 108 | + │ Defined at <no location info>
|
|
| 109 | + └
|
|
| 110 | + |
| ... | ... | @@ -8,4 +8,5 @@ test('HieVdq', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUti |
| 8 | 8 | test('T23540', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info'])
|
| 9 | 9 | test('T23120', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info'])
|
| 10 | 10 | test('T24544', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info'])
|
| 11 | -test('HieGadtConSigs', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) |
|
| \ No newline at end of file | ||
| 11 | +test('HieGadtConSigs', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info'])
|
|
| 12 | +test('T25709', [extra_run_opts('"' + config.libdir + '"'), extra_files(['TestUtils.hs'])], compile_and_run, ['-package ghc -fwrite-ide-info']) |