1. 20 Jun, 2019 5 commits
    • John Ericson's avatar
      Move 'Platform' to ghc-boot · bff2f24b
      John Ericson authored
      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
    • Simon Peyton Jones's avatar
      Comments and tiny refactor · 3ae23992
      Simon Peyton Jones authored
      * 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
    • Simon Peyton Jones's avatar
      Fix typechecking of partial type signatures · 48fb3482
      Simon Peyton Jones authored
      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
      Fix two places that failed the substitution invariant · 3c9b57b0
      Simon Peyton Jones authored
      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
    • Ömer Sinan Ağacan's avatar
      Properly trim IdInfos of DFunIds and PatSyns in TidyPgm · 9d58554f
      Ömer Sinan Ağacan authored
      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
  2. 19 Jun, 2019 1 commit
  3. 18 Jun, 2019 2 commits
    • Andreas Klebinger's avatar
      Make sure mkSplitUniqSupply stores the precomputed mask only. · 4549cadf
      Andreas Klebinger authored
      mkSplitUniqSupply was lazy on the boxed char.
      
      This caused a bunch of issues:
      * The closure captured the boxed Char
      * The mask was recomputed on every split of the supply.
      * It also caused the allocation of MkSplitSupply to happen in it's own
      (allocated) closure. The reason of which I did not further investigate.
      
      We know force the computation of the mask inside mkSplitUniqSupply.
      * This way the mask is computed at most once per UniqSupply creation.
      * It allows ww to kick in, causing the closure to retain the unboxed
      value.
      
      Requesting Uniques in a loop is now faster by about 20%.
      
      I did not check the impact on the overall compiler, but I added a test
      to avoid regressions.
      4549cadf
    • Ben Gamari's avatar
      SafeHaskell: Don't throw -Wsafe warning if module is declared Safe · 29ec33cd
      Ben Gamari authored
      Fixes #16689.
      29ec33cd
  4. 16 Jun, 2019 4 commits
  5. 15 Jun, 2019 1 commit
  6. 14 Jun, 2019 5 commits
    • Ben Gamari's avatar
      PrelRules: Don't break let/app invariant in shiftRule · 5279dda8
      Ben Gamari authored
      Previously shiftRule would rewrite as invalid shift like
      ```
      let x = I# (uncheckedIShiftL# n 80)
      in ...
      ```
      to
      ```
      let x = I# (error "invalid shift")
      in ...
      ```
      However, this breaks the let/app invariant as `error` is not
      okay-for-speculation. There isn't an easy way to avoid this so let's not
      try. Instead we just take advantage of the undefined nature of invalid
      shifts and return zero.
      
      Fixes #16742.
      5279dda8
    • Andrew Martin's avatar
      Implement the -XUnliftedNewtypes extension. · effdd948
      Andrew Martin authored
      GHC Proposal: 0013-unlifted-newtypes.rst
      Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/98
      Issues: #15219, #1311, #13595, #15883
      Implementation Details:
        Note [Implementation of UnliftedNewtypes]
        Note [Unifying data family kinds]
        Note [Compulsory newtype unfolding]
      
      This patch introduces the -XUnliftedNewtypes extension. When this
      extension is enabled, GHC drops the restriction that the field in
      a newtype must be of kind (TYPE 'LiftedRep). This allows types
      like Int# and ByteArray# to be used in a newtype. Additionally,
      coerce is made levity-polymorphic so that it can be used with
      newtypes over unlifted types.
      
      The bulk of the changes are in TcTyClsDecls.hs. With -XUnliftedNewtypes,
      getInitialKind is more liberal, introducing a unification variable to
      return the kind (TYPE r0) rather than just returning (TYPE 'LiftedRep).
      When kind-checking a data constructor with kcConDecl, we attempt to
      unify the kind of a newtype with the kind of its field's type. When
      typechecking a data declaration with tcTyClDecl, we again perform a
      unification. See the implementation note for more on this.
      Co-authored-by: Richard Eisenberg's avatarRichard Eisenberg <rae@richarde.dev>
      effdd948
    • Andreas Klebinger's avatar
      3bc6df32
    • Ömer Sinan Ağacan's avatar
      Remove unused Unique field from StgFCallOp · 71e75ba6
      Ömer Sinan Ağacan authored
      Fixes #16696
      71e75ba6
    • Ben Gamari's avatar
      Maintain separate flags for C++ compiler invocations · 7bc5d6c6
      Ben Gamari authored
      Previously we would pass flags intended for the C compiler to the C++
      compiler (see #16738). This would cause, for instance, `-std=gnu99` to
      be passed to the C++ compiler, causing spurious test failures. Fix this
      by maintaining a separate set of flags for C++ compilation invocations.
      7bc5d6c6
  7. 13 Jun, 2019 1 commit
    • Ben Gamari's avatar
      PrelRules: Ensure that string unpack/append rule fires with source notes · a657543c
      Ben Gamari authored
      Previously the presence of source notes could hide nested applications
      of `unpackFoldrCString#` from our constant folding logic. For instance,
      consider the expression:
      
      ```haskell
      unpackFoldrCString# "foo" c (unpackFoldrCString# "baz" c n)
      ```
      
      Specifically, ticks appearing in two places can defeat the rule:
      
        a. Surrounding the inner application of `unpackFoldrCString#`
        b. Surrounding the fold function, `c`
      
      The latter caused the `str_rules` testcase to fail when `base` was built
      with `-g3`.
      
      Fixes #16740.
      a657543c
  8. 12 Jun, 2019 1 commit
  9. 11 Jun, 2019 3 commits
    • Alp Mestanogullari's avatar
      Refine the GHCI macro into HAVE[_{INTERNAL, EXTERNAL}]_INTERPRETER · 39f50bff
      Alp Mestanogullari authored
      As discussed in #16331, the GHCI macro, defined through 'ghci' flags
      in ghc.cabal.in, ghc-bin.cabal.in and ghci.cabal.in, is supposed to indicate
      whether GHC is built with support for an internal interpreter, that runs in
      the same process. It is however overloaded in a few places to mean
      "there is an interpreter available", regardless of whether it's an internal
      or external interpreter.
      
      For the sake of clarity and with the hope of more easily being able to
      build stage 1 GHCs with external interpreter support, this patch splits
      the previous GHCI macro into 3 different ones:
      
      - HAVE_INTERNAL_INTERPRETER: GHC is built with an internal interpreter
      - HAVE_EXTERNAL_INTERPRETER: GHC is built with support for external interpreters
      - HAVE_INTERPRETER: HAVE_INTERNAL_INTERPRETER || HAVE_EXTERNAL_INTERPRETER
      39f50bff
    • Yuras's avatar
      Warn about unused packages · fe7e7e4a
      Yuras authored
      Reviewers: bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: hvr, simonpj, mpickering, rwbarton, carter
      
      GHC Trac Issues: #15838
      
      Differential Revision: https://phabricator.haskell.org/D5285
      fe7e7e4a
    • Richard Eisenberg's avatar
      0345b1b0
  10. 10 Jun, 2019 1 commit
  11. 09 Jun, 2019 7 commits
    • John Ericson's avatar
      Remove CPP ensuring word size is 32 or 64 bits around Addr# <-> int# primops · 5023adce
      John Ericson authored
      It shouldn't be needed these days, and those primops are "highly
      deprecated" anyways.
      
      This fits with my plans because it removes one bit of target-dependence
      of the builtin primops, and this is the hardest part of GHC to make
      multi-target.
      
      CC @carter
      5023adce
    • Richard Eisenberg's avatar
      1c7bb03d
    • Alex D's avatar
      Do not report error if Name in pragma is unbound · ed20412a
      Alex D authored
      ed20412a
    • Richard Eisenberg's avatar
      Fix #16517 by bumping the TcLevel for method sigs · a22e51ea
      Richard Eisenberg authored
      There were actually two bugs fixed here:
      
      1. candidateQTyVarsOfType needs to be careful that it does not
         try to zap metavariables from an outer scope as "naughty"
         quantification candidates. This commit adds a simple check
         to avoid doing so.
      
      2. We weren't bumping the TcLevel in kcHsKindSig, which was used
         only for class method sigs. This mistake led to the acceptance
         of
      
           class C a where
             meth :: forall k. Proxy (a :: k) -> ()
      
         Note that k is *locally* quantified. This patch fixes the
         problem by using tcClassSigType, which correctly bumps the
         level. It's a bit inefficient because tcClassSigType does other
         work, too, but it would be tedious to repeat much of the code
         there with only a few changes. This version works well and is
         simple.
      
      And, while updating comments, etc., I noticed that tcRnType was
      missing a pushTcLevel, leading to #16767, which this patch also
      fixes, by bumping the level. In the refactoring here, I also
      use solveEqualities. This initially failed ghci/scripts/T15415,
      but that was fixed by teaching solveEqualities to respect
      -XPartialTypeSignatures.
      
      This patch also cleans up some Notes around error generation that
      came up in conversation.
      
      Test case: typecheck/should_fail/T16517, ghci/scripts/T16767
      a22e51ea
    • KevinBuhr's avatar
      Handle trailing path separator in package DB names (#16360) · 9d238791
      KevinBuhr authored
      Package DB directories with trailing separator (provided via
      GHC_PACKAGE_PATH or via -package-db) resulted in incorrect calculation of
      ${pkgroot} substitution variable.  Keep the trailing separator while
      resolving as directory or file, but remove it before dropping the last
      path component with takeDirectory.
      
      Closes #16360.
      9d238791
    • Simon Jakobi's avatar
      Small refactorings in ExtractDocs · b9fe91fc
      Simon Jakobi authored
      b9fe91fc
    • chessai's avatar
      Introduce log1p and expm1 primops · f7370333
      chessai authored
      Previously log and exp were primitives yet log1p and expm1 were FFI
      calls. Fix this non-uniformity.
      f7370333
  12. 08 Jun, 2019 1 commit
  13. 07 Jun, 2019 6 commits
    • Zejun Wu's avatar
    • Simon Peyton Jones's avatar
      Preserve ShadowInfo when rewriting evidence · da26ffe7
      Simon Peyton Jones authored
      When the canonicaliser rewrites evidence of a Wanted, it
      should preserve the ShadowInfo (ctev_nosh) field.  That is,
      a WDerive should rewrite to WDerive, and WOnly to WOnly.
      
      Previously we were unconditionally making a WDeriv, thereby
      rewriting WOnly to WDeriv.  This bit Nick Frisby (issue #16735)
      in the context of his plugin, but we don't have a compact test
      case.
      
      The fix is simple, but does involve a bit more plumbing,
      to pass the old ShadowInfo around, to use when building
      the new Wanted.
      da26ffe7
    • John Ericson's avatar
      Factor out 'getLibDir' / 'getBaseDir' into a new GHC.BaseDir ghc-boot module · 387050d0
      John Ericson authored
      ghc-pkg and ghc already both needed this. I figure it is better to
      deduplicate, especially seeing that changes to one (FreeBSD CPP) didn't
      make it to the other.
      
      Additionally in !1090 I make ghc-pkg look up the settings file, which
      makes it use the top dir a bit more widely. If that lands, any
      difference in the way they find the top dir would be more noticable.
      
      That change also means sharing more code between ghc and ghc-package
      (namely the settings file parsing code), so I'd think it better to get
      off the slipperly slope of duplicating code now.
      387050d0
    • Roland Senn's avatar
      Fix #16700: Tiny errors in output of GHCi commands :forward and :info · d1dc0ed7
      Roland Senn authored
      `:info Coercible` now outputs the correct section number of the GHCi User's guide together with the secion title.
      
      `:forward x` gives the correct syntax hint.
      d1dc0ed7
    • Sebastian Graf's avatar
      TmOracle: Replace negative term equalities by refutable PmAltCons · e963beb5
      Sebastian Graf authored
      The `PmExprEq` business was a huge hack and was at the same time vastly
      too powerful and not powerful enough to encode negative term equalities,
      i.e. facts of the form "forall y. x ≁ Just y".
      
      This patch introduces the concept of 'refutable shapes': What matters
      for the pattern match checker is being able to encode knowledge of the
      kind "x can no longer be the literal 5". We encode this knowledge in a
      `PmRefutEnv`, mapping a set of newly introduced `PmAltCon`s (which are
      just `PmLit`s at the moment) to each variable denoting above
      inequalities.
      
      So, say we have `x ≁ 42 ∈ refuts` in the term oracle context and
      try to solve an equality like `x ~ 42`. The entry in the refutable
      environment will immediately lead to a contradiction.
      
      This machinery renders the whole `PmExprEq` and `ComplexEq` business
      unnecessary, getting rid of a lot of (mostly dead) code.
      
      See the Note [Refutable shapes] in TmOracle for a place to start.
      
      Metric Decrease:
          T11195
      e963beb5
    • Andrew Martin's avatar
      [skip ci] Improve the documentation of the CNF primops. In this context, the... · d3915b30
      Andrew Martin authored
      [skip ci] Improve the documentation of the CNF primops. In this context, the term "size" is ambiguous and is now avoided. Additionally, the distinction between a CNF and the blocks that comprise it has been emphasize. The vocabulary has been made more consistent with the vocabulary in the C source for CNF.
      d3915b30
  14. 04 Jun, 2019 2 commits
    • xldenis's avatar
      Add GHCi :instances command · 002594b7
      xldenis authored
      This commit adds the `:instances` command to ghci following proosal
      number 41.
      
      This makes it possible to query which instances are available to a given
      type.
      
      The output of this command is all the possible instances with type
      variables and constraints instantiated.
      002594b7
    • Andrew Martin's avatar
      Use a better strategy for determining the offset applied to foreign function... · db78ac6f
      Andrew Martin authored
      Use a better strategy for determining the offset applied to foreign function arguments that have an unlifted boxed type. We used to use the type of the argument. We now use the type of the foreign function. Add a test to confirm that the roundtrip conversion between an unlifted boxed type and Any is sound in the presence of a foreign function call.
      db78ac6f