Skip to content
Commits on Source (24)
  • Ömer Sinan Ağacan's avatar
    Fix a Note name in CmmNode · 8584430e
    Ömer Sinan Ağacan authored
    ("Continuation BlockIds" is referenced in CmmProcPoint)
    
    [skip ci]
    8584430e
  • Ömer Sinan Ağacan's avatar
    Properly trim IdInfos of DFunIds and PatSyns in TidyPgm · 9d58554f
    Ömer Sinan Ağacan authored and Marge Bot's avatar Marge Bot committed
    Not doing this right caused #16608. We now properly trim IdInfos of
    DFunIds and PatSyns.
    
    Some further refactoring done by SPJ.
    
    Two regression tests T16608_1 and T16608_2 added.
    
    Fixes #16608
    9d58554f
  • Roland Senn's avatar
    Fix #1620: ModBreaks.modBreaks_array not initialised · 39c758e1
    Roland Senn authored and Marge Bot's avatar Marge Bot committed
    After a :cd command and after setting some package flags,
    GHCi unloads all loaded modules by resetting the list of targets.
    
    This patch deletes eventually defined debugger breakpoints, before GHCi resets the target list.
    
    The common code is factored out into the new function clearAllTargets.
    39c758e1
  • Simon Peyton Jones's avatar
    Fix two places that failed the substitution invariant · 3c9b57b0
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    The substition invariant relies on keeping the in-scope
    set in sync, and we weren't always doing so, which means that
    a DEBUG compiler crashes sometimes with an assertion failure
    
    This patch fixes a couple more cases.  Still not validate
    clean (with -DEEBUG) but closer!
    3c9b57b0
  • Simon Peyton Jones's avatar
    Fix typechecking of partial type signatures · 48fb3482
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    Partial type sigs had grown hair.  tcHsParialSigType was
    doing lots of unnecessary work, and tcInstSig was cloning it
    unnecessarily -- and the result didn't even work: #16728.
    
    This patch cleans it all up, described by TcHsType
      Note [Checking parital type signatures]
    
    I basically just deleted code... but very carefully!
    
    Some refactoring along the way
    
    * Distinguish more explicintly between "anonymous" wildcards "_"
      and "named" wildcards "_a".  I changed the names of a number
      of functions to make this distinction much more apparent.
    
    The patch also revealed that the code in `TcExpr`
    that implements the special typing rule for `($)` was wrong.
    It called `getRuntimeRep` in a situation where where was no
    particular reason to suppose that the thing had kind `TYPE r`.
    
    This caused a crash in typecheck/should_run/T10846.
    
    The fix was easy, and actually simplifies the code in `TcExpr`
    quite a bit.  Hooray.
    48fb3482
  • Simon Peyton Jones's avatar
    Comments and tiny refactor · 3ae23992
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    * Added Note [Quantified varaibles in partial type signatures]
      in TcRnTypes
    
    * Kill dVarSetElemsWellScoped; it was only called in
      one function, quantifyTyVars.  I inlined it because it
      was only scopedSort . dVarSetElems
    
    * Kill Type.tyCoVarsOfBindersWellScoped, never called.
    3ae23992
  • John Ericson's avatar
    Move 'Platform' to ghc-boot · bff2f24b
    John Ericson authored and Marge Bot's avatar Marge Bot committed
    ghc-pkg needs to be aware of platforms so it can figure out which
    subdire within the user package db to use. This is admittedly
    roundabout, but maybe Cabal could use the same notion of a platform as
    GHC to good affect too.
    bff2f24b
  • John Ericson's avatar
    Add 'stringEncodeArch' and 'stringEncodeOS' to GHC.Platform · a298b96e
    John Ericson authored and Marge Bot's avatar Marge Bot committed
    a298b96e
  • John Ericson's avatar
    ghc-pkg needs settings file to un-hardcode target platform · d406a16a
    John Ericson authored and Marge Bot's avatar Marge Bot committed
    This matches GHC itself getting the target platform from there.
    d406a16a
  • Ben Gamari's avatar
    users-guide: Fix a variety of broken links and syntax · aa4891a7
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    aa4891a7
  • Ben Gamari's avatar
    users-guide: Update -Wsafe description for #16689 · fe819dd6
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    We no longer emit a warning when a safe module is explicitly declared as
    such.
    fe819dd6
  • Matthías Páll Gissurarson's avatar
    Add HoleFitPlugins and RawHoleFits · c311277b
    Matthías Páll Gissurarson authored
    This patch adds a new kind of plugin, Hole fit plugins. These plugins
    can change what candidates are considered when looking for valid hole
    fits, and add hole fits of their own. The type of a plugin is relatively
    simple,
    
    ```
    type FitPlugin = TypedHole -> [HoleFit] -> TcM [HoleFit]
    type CandPlugin = TypedHole -> [HoleFitCandidate] -> TcM [HoleFitCandidate]
    data HoleFitPlugin = HoleFitPlugin { candPlugin :: CandPlugin
                                       , fitPlugin :: FitPlugin }
    
    data TypedHole = TyH { tyHRelevantCts :: Cts
                           -- ^ Any relevant Cts to the hole
                         , tyHImplics :: [Implication]
                           -- ^ The nested implications of the hole with the
                           --   innermost implication first.
                         , tyHCt :: Maybe Ct
                           -- ^ The hole constraint itself, if available.
                         }
    
    This allows users and plugin writers to interact with the candidates and
    fits as they wish, even going as far as to allow them to reimplement the
    current functionality (since `TypedHole` contains all the relevant
    information).
    
    As an example, consider the following plugin:
    
    ```
    module HolePlugin where
    
    import GhcPlugins
    
    import TcHoleErrors
    
    import Data.List (intersect, stripPrefix)
    import RdrName (importSpecModule)
    
    import TcRnTypes
    
    import System.Process
    
    plugin :: Plugin
    plugin = defaultPlugin { holeFitPlugin = hfp, pluginRecompile = purePlugin }
    
    hfp :: [CommandLineOption] -> Maybe HoleFitPluginR
    hfp opts = Just (fromPureHFPlugin $ HoleFitPlugin (candP opts) (fp opts))
    
    toFilter :: Maybe String -> Maybe String
    toFilter = flip (>>=) (stripPrefix "_module_")
    
    replace :: Eq a => a -> a -> [a] -> [a]
    replace match repl str = replace' [] str
      where
        replace' sofar (x:xs) | x == match = replace' (repl:sofar) xs
        replace' sofar (x:xs) = replace' (x:sofar) xs
        replace' sofar [] = reverse sofar
    
    -- | This candidate plugin filters the candidates by module,
    --   using the name of the hole as module to search in
    candP :: [CommandLineOption] -> CandPlugin
    candP _ hole cands =
      do let he = case tyHCt hole of
                    Just (CHoleCan _ h) -> Just (occNameString $ holeOcc h)
                    _ -> Nothing
         case toFilter he of
            Just undscModName -> do let replaced = replace '_' '.' undscModName
                                    let res = filter (greNotInOpts [replaced]) cands
                                    return $ res
            _ -> return cands
      where greNotInOpts opts (GreHFCand gre)  = not $ null $ intersect (inScopeVia gre) opts
            greNotInOpts _ _ = True
            inScopeVia = map (moduleNameString . importSpecModule) . gre_imp
    
    -- Yes, it's pretty hacky, but it is just an example :)
    searchHoogle :: String -> IO [String]
    searchHoogle ty = lines <$> (readProcess "hoogle" [(show ty)] [])
    
    fp :: [CommandLineOption] -> FitPlugin
    fp ("hoogle":[]) hole hfs =
        do dflags <- getDynFlags
           let tyString = showSDoc dflags . ppr . ctPred <$> tyHCt hole
           res <- case tyString of
                    Just ty -> liftIO $ searchHoogle ty
                    _ -> return []
           return $ (take 2 $ map (RawHoleFit . text . ("Hoogle says: " ++)) res) ++ hfs
    fp _ _ hfs = return hfs
    
    ```
    
    with this plugin available, you can compile the following file
    
    ```
    {-# OPTIONS -fplugin=HolePlugin -fplugin-opt=HolePlugin:hoogle #-}
    module Main where
    
    import Prelude hiding (head, last)
    
    import Data.List (head, last)
    
    t :: [Int] -> Int
    t = _module_Prelude
    
    g :: [Int] -> Int
    g = _module_Data_List
    
    main :: IO ()
    main = print $ t [1,2,3]
    ```
    
    and get the following output:
    
    ```
    Main.hs:14:5: error:
        • Found hole: _module_Prelude :: [Int] -> Int
          Or perhaps ‘_module_Prelude’ is mis-spelled, or not in scope
        • In the expression: _module_Prelude
          In an equation for ‘t’: t = _module_Prelude
        • Relevant bindings include
            t :: [Int] -> Int (bound at Main.hs:14:1)
          Valid hole fits include
            Hoogle says: GHC.List length :: [a] -> Int
            Hoogle says: GHC.OldList length :: [a] -> Int
            t :: [Int] -> Int (bound at Main.hs:14:1)
            g :: [Int] -> Int (bound at Main.hs:17:1)
            length :: forall (t :: * -> *) a. Foldable t => t a -> Int
              with length @[] @Int
              (imported from ‘Prelude’ at Main.hs:5:1-34
               (and originally defined in ‘Data.Foldable’))
            maximum :: forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
              with maximum @[] @Int
              (imported from ‘Prelude’ at Main.hs:5:1-34
               (and originally defined in ‘Data.Foldable’))
            (Some hole fits suppressed; use -fmax-valid-hole-fits=N or -fno-max-valid-hole-fits)
       |
    14 | t = _module_Prelude
       |     ^^^^^^^^^^^^^^^
    
    Main.hs:17:5: error:
        • Found hole: _module_Data_List :: [Int] -> Int
          Or perhaps ‘_module_Data_List’ is mis-spelled, or not in scope
        • In the expression: _module_Data_List
          In an equation for ‘g’: g = _module_Data_List
        • Relevant bindings include
            g :: [Int] -> Int (bound at Main.hs:17:1)
          Valid hole fits include
            Hoogle says: GHC.List length :: [a] -> Int
            Hoogle says: GHC.OldList length :: [a] -> Int
            g :: [Int] -> Int (bound at Main.hs:17:1)
            head :: forall a. [a] -> a
              with head @Int
              (imported from ‘Data.List’ at Main.hs:7:19-22
               (and originally defined in ‘GHC.List’))
            last :: forall a. [a] -> a
              with last @Int
              (imported from ‘Data.List’ at Main.hs:7:25-28
               (and originally defined in ‘GHC.List’))
       |
    17 | g = _module_Data_List
    
    ```
    
    This relatively simple plugin has two functions, as an example of what
    is possible to do with hole fit plugins. The candidate plugin starts by
    filtering the candidates considered by module, indicated by the name of
    the hole (`_module_Data_List`). The second function is in the fit
    plugin, where the plugin invokes a local hoogle instance to search by
    the type of the hole.
    
    By adding the `RawHoleFit` type, we can also allow these completely free
    suggestions, used in the plugin above to display fits found by Hoogle.
    
    Additionally, the `HoleFitPluginR` wrapper can be used for plugins to
    maintain state between invocations, which can be used to speed up
    invocation of plugins that have expensive initialization.
    
    ```
    -- | HoleFitPluginR adds a TcRef to hole fit plugins so that plugins can
    -- track internal state. Note the existential quantification, ensuring that
    -- the state cannot be modified from outside the plugin.
    data HoleFitPluginR = forall s. HoleFitPluginR
      { hfPluginInit :: TcM (TcRef s)
        -- ^ Initializes the TcRef to be passed to the plugin
      , hfPluginRun :: TcRef s -> HoleFitPlugin
        -- ^ The function defining the plugin itself
      , hfPluginStop :: TcRef s -> TcM ()
        -- ^ Cleanup of state, guaranteed to be called even on error
      }
    ```
    
    Of course, the syntax here is up for debate, but hole fit plugins allow
    us to experiment relatively easily with ways to interact with
    typed-holes without having to dig deep into GHC.
    
    Reviewers: bgamari
    
    Subscribers: rwbarton, carter
    
    Differential Revision: https://phabricator.haskell.org/D5373
    c311277b
  • Ben Gamari's avatar
    testsuite: Skip dynamicToo006 when dynamic linking is not available · 2485c08a
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    This was previously failling on Windows.
    2485c08a
  • Ben Gamari's avatar
    testsuite: Mark T3372 as fragile on Windows · aa516431
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    On Windows we must lock package databases even when opening for
    read-only access. This means that concurrent GHC sessions are very
    likely to fail with file lock contention.
    
    See #16773.
    aa516431
  • Ben Gamari's avatar
    testsuite: Add stderr output for UnsafeInfered02 on Windows · 2eedb120
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    This test uses TemplateHaskell causing GHC to build dynamic objects on
    platforms where dynamic linking is available. However, Windows doesn't support
    dynamic linking. Consequently the test would fail on Windows with:
    
    ```patch
    --- safeHaskell/safeInfered/UnsafeInfered02.run/UnsafeInfered02.stderr.normalised	2019-06-04 15:10:10.521594200 +0000
    +++ safeHaskell/safeInfered/UnsafeInfered02.run/UnsafeInfered02.comp.stderr.normalised	2019-06-04 15:10:10.523546200 +0000
    @@ -1,5 +1,5 @@
    -[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o, UnsafeInfered02_A.dyn_o )
    -[2 of 2] Compiling UnsafeInfered02  ( UnsafeInfered02.hs, UnsafeInfered02.o, UnsafeInfered02.dyn_o )
    +[1 of 2] Compiling UnsafeInfered02_A ( UnsafeInfered02_A.hs, UnsafeInfered02_A.o )
    +[2 of 2] Compiling UnsafeInfered02  ( UnsafeInfered02.hs, UnsafeInfered02.o )
    
     UnsafeInfered02.hs:4:1:
         UnsafeInfered02_A: Can't be safely imported!
    ```
    
    The other approach I considered for this issue is to pass `-v0` to GHC.
    However, I felt we should probably do this consistently for all of the tests in
    this directory and this would take more time than I currently have.
    2eedb120
  • Ben Gamari's avatar
    testsuite: Mark OldModLocation as broken on Windows · 3967d13a
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Strangely the path it emits contains duplicate path delimiters (#16772),
    ```patch
    --- ghc-api/downsweep/OldModLocation.run/OldModLocation.stderr.normalised	2019-06-04 14:40:26.326075000 +0000
    +++ ghc-api/downsweep/OldModLocation.run/OldModLocation.run.stderr.normalised	2019-06-04 14:40:26.328029200 +0000
    @@ -1 +1 @@
    -[Just "A.hs",Just "mydir/B.hs"]
    +[Just "A.hs",Just "mydir//B.hs"]
    ```
    3967d13a
  • Ben Gamari's avatar
    testsuite: Mark T7170 as broken on Windows · 31f2ea68
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Due to #16801.
    31f2ea68
  • Ben Gamari's avatar
    testsuite: Mark T7702 as broken on Windows · 7bd1c3e1
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    Due to #16799.
    7bd1c3e1
  • Ben Gamari's avatar
    testsuite: Mark T15633a and T15633b as fragile on Windows · 84900724
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    As noted in #16813, these tests seem to be fragile on Windows.
    84900724
  • Ben Gamari's avatar
    linker: Disable code unloading · 49fff41d
    Ben Gamari authored and Marge Bot's avatar Marge Bot committed
    As noted in #16841, there are currently a variety of bugs in the
    unloading logic. These only affect Windows since code unloading is
    disabled on Linux, where we build with `GhcDynamic=YES` by default.
    
    In the interest of getting the tree green on Windows disable code
    unloading until the issues are resolved.
    49fff41d
  • Ben Gamari's avatar
    testsuite: Mark T16608_* as fragile on Darwin · e0595d22
    Ben Gamari authored
    As noted in #16855.
    e0595d22
  • Ben Gamari's avatar
    testsuite: A major revamp of the driver · fab0397a
    Ben Gamari authored
    This tries to put the testsuite driver into a slightly more maintainable
    condition:
    
    * Add type annotations where easily done
    * Use pathlib.Path instead of str paths
    * Make it pass the mypy typechecker
    fab0397a
  • Ben Gamari's avatar
    testsuite: Fix a few issues in JUnit output · 2e68e1e6
    Ben Gamari authored
     * Make it pass mypy
     * Fix a typo in test name field
     * Report more stderr output
     * Report stdout output
    2e68e1e6
  • Ben Gamari's avatar
    gitlab-ci: Add testsuite typechecking lint · 3486a0ff
    Ben Gamari authored
    3486a0ff
......@@ -71,6 +71,7 @@ ghc-linters:
refs:
- merge_requests
# Run mypy Python typechecker on linter scripts.
lint-linters:
<<: *only-default
stage: lint
......@@ -81,6 +82,7 @@ lint-linters:
tags:
- lint
# Check that .T files all parse by listing broken tests.
lint-testsuite:
<<: *only-default
stage: lint
......@@ -91,6 +93,17 @@ lint-testsuite:
tags:
- lint
# Run mypy Python typechecker on testsuite driver
typecheck-testsuite:
<<: *only-default
stage: lint
image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
script:
- mypy testsuite/driver/runtests.py
dependencies: []
tags:
- lint
# We allow the submodule checker to fail when run on merge requests (to
# accomodate, e.g., haddock changes not yet upstream) but not on `master` or
# Marge jobs.
......
......@@ -61,7 +61,7 @@ import BasicTypes
import Binary
import Constants
import DynFlags
import Platform
import GHC.Platform
import UniqFM
import Util
......
......@@ -19,7 +19,7 @@ module PatSyn (
patSynInstArgTys, patSynInstResTy, patSynFieldLabels,
patSynFieldType,
tidyPatSynIds, pprPatSynType
updatePatSynIds, pprPatSynType
) where
#include "HsVersions.h"
......@@ -417,8 +417,8 @@ patSynMatcher = psMatcher
patSynBuilder :: PatSyn -> Maybe (Id, Bool)
patSynBuilder = psBuilder
tidyPatSynIds :: (Id -> Id) -> PatSyn -> PatSyn
tidyPatSynIds tidy_fn ps@(MkPatSyn { psMatcher = matcher, psBuilder = builder })
updatePatSynIds :: (Id -> Id) -> PatSyn -> PatSyn
updatePatSynIds tidy_fn ps@(MkPatSyn { psMatcher = matcher, psBuilder = builder })
= ps { psMatcher = tidy_pr matcher, psBuilder = fmap tidy_pr builder }
where
tidy_pr (id, dummy) = (tidy_fn id, dummy)
......
......@@ -124,7 +124,7 @@ import CostCentre
import Outputable
import FastString
import DynFlags
import Platform
import GHC.Platform
import UniqSet
import Util
import PprCore ( {- instances -} )
......
......@@ -16,7 +16,7 @@ import Hoopl.Label
import Hoopl.Collections
import Hoopl.Dataflow
import Module
import Platform
import GHC.Platform
import Digraph
import CLabel
import PprCmmDecl ()
......
......@@ -13,7 +13,7 @@ import Cmm (Convention(..))
import PprCmm ()
import DynFlags
import Platform
import GHC.Platform
import Outputable
-- Calculate the 'GlobalReg' or stack locations for function call
......
......@@ -45,7 +45,7 @@ import Stream (Stream)
import qualified Stream
import Hoopl.Collections
import Platform
import GHC.Platform
import Maybes
import DynFlags
import Panic
......
......@@ -114,7 +114,7 @@ data CmmNode e x where
cml_cont :: Maybe Label,
-- Label of continuation (Nothing for return or tail call)
--
-- Note [Continuation BlockId]: these BlockIds are called
-- Note [Continuation BlockIds]: these BlockIds are called
-- Continuation BlockIds, and are the only BlockIds that can
-- occur in CmmExprs, namely as (CmmLit (CmmBlock b)) or
-- (CmmStackSlot (Young b) _).
......
......@@ -25,7 +25,7 @@ import DynFlags
import Util
import Outputable
import Platform
import GHC.Platform
import Data.Bits
import Data.Maybe
......
......@@ -237,7 +237,7 @@ import CmmMonad
import CostCentre
import ForeignCall
import Module
import Platform
import GHC.Platform
import Literal
import Unique
import UniqFM
......
......@@ -26,7 +26,7 @@ import ErrUtils
import HscTypes
import Control.Monad
import Outputable
import Platform
import GHC.Platform
-----------------------------------------------------------------------------
-- | Top level driver for C-- pipeline
......
......@@ -23,7 +23,7 @@ import Data.List (sortBy)
import Maybes
import Control.Monad
import Outputable
import Platform
import GHC.Platform
import UniqSupply
import Hoopl.Block
import Hoopl.Collections
......
......@@ -14,7 +14,7 @@ import Hoopl.Label
import Hoopl.Collections
import Hoopl.Graph
import CodeGen.Platform
import Platform (isARM, platformArch)
import GHC.Platform (isARM, platformArch)
import DynFlags
import Unique
......
......@@ -44,7 +44,7 @@ import CPrim
import DynFlags
import FastString
import Outputable
import Platform
import GHC.Platform
import UniqSet
import UniqFM
import Unique
......
......@@ -49,7 +49,7 @@ import GhcPrelude
import BasicTypes( ConTagZ )
import DynFlags
import Outputable
import Platform
import GHC.Platform
import FastString
import Data.Word
......
......@@ -6,7 +6,7 @@ module CodeGen.Platform
import GhcPrelude
import CmmExpr
import Platform
import GHC.Platform
import Reg
import qualified CodeGen.Platform.ARM as ARM
......
......@@ -44,7 +44,7 @@ import RepType (countConRepArgs)
import Literal
import PrelInfo
import Outputable
import Platform
import GHC.Platform
import Util
import MonadUtils (mapMaybeM)
......
......@@ -31,7 +31,7 @@ import StgCmmHeap
import StgCmmProf ( costCentreFrom )
import DynFlags
import Platform
import GHC.Platform
import BasicTypes
import BlockId
import MkGraph
......
......@@ -53,7 +53,7 @@ import DynFlags
import Util
import Pair
import Outputable
import Platform
import GHC.Platform
import FastString
import Name ( NamedThing(..), nameSrcSpan )
import SrcLoc ( SrcSpan(..), realSrcLocSpan, mkRealSrcLoc )
......
......@@ -9,7 +9,7 @@ The code for *top-level* bindings is in TidyPgm.
{-# LANGUAGE CPP #-}
module CoreTidy (
tidyExpr, tidyVarOcc, tidyRule, tidyRules, tidyUnfolding
tidyExpr, tidyRule, tidyRules, tidyUnfolding
) where
#include "HsVersions.h"
......