17 months agoTypofixes in comments and whitespace only [ci skip]
Gabor Greif [Tue, 26 Jun 2018 13:29:14 +0000 (15:29 +0200)] 
Typofixes in comments and whitespace only [ci skip]

17 months agoRemove dead code
Simon Peyton Jones [Tue, 26 Jun 2018 11:07:27 +0000 (12:07 +0100)] 
Remove dead code

17 months agoA bit more tc-tracking in TcUnify.uUnfilledVar
Simon Peyton Jones [Tue, 26 Jun 2018 11:07:08 +0000 (12:07 +0100)] 
A bit more tc-tracking in TcUnify.uUnfilledVar

17 months agoFix TcLevel manipulation in TcDerivInfer.simplifyDeriv
Simon Peyton Jones [Mon, 25 Jun 2018 16:42:57 +0000 (17:42 +0100)] 
Fix TcLevel manipulation in TcDerivInfer.simplifyDeriv

The level numbers we were getting simply didn't obey the
invariant (ImplicInv) in TcType
   Note [TcLevel and untouchable type variables]

That leads to chaos. Easy to fix.  I improved the documentation.

I also added an assertion in TcSimplify that checks that
level numbers go up by 1 as we dive inside implications, so
that we catch the problem at source rather than than through
its obscure consequences.

That in turn showed up that TcRules was also generating
constraints that didn't obey (ImplicInv), so I fixed that too.
I have no idea what consequences were lurking behing that
bug, but anyway now it's fixed.  Hooray.

17 months agoAPI Annotations when parsing typapp
Alan Zimmerman [Tue, 26 Jun 2018 09:07:07 +0000 (11:07 +0200)] 
API Annotations when parsing typapp

Make sure the original annotations are still accessible for a promoted

Closes #15303

17 months agoRecord some notes about "innocuous" transformations
Simon Peyton Jones [Thu, 7 Jun 2018 08:25:33 +0000 (09:25 +0100)] 
Record some notes about "innocuous" transformations

I wondered if some transformations (ticks) might be "innocuous",
in the sense that they do not unlock a later transformation that
does not occur in the same pass.  If so, we could refrain from
bumping the overall tick-count for such innocuous transformations,
and perhaps terminate the simplifier one pass earlier.

BUt alas I found that virtually nothing was innocuous!  This
commit just adds a Note to record what I learned, in case
anyone wants to try again.

17 months agoRemove unused BottomFound from Tick
Simon Peyton Jones [Thu, 7 Jun 2018 08:19:36 +0000 (09:19 +0100)] 
Remove unused BottomFound from Tick

17 months agoMore misc comments
Simon Peyton Jones [Thu, 7 Jun 2018 08:17:22 +0000 (09:17 +0100)] 
More misc comments

... plus, reorder equations in toIfaceVar to improve
legibility.  No change in behaviour.

17 months agoComents and debug tracing only
Simon Peyton Jones [Thu, 31 May 2018 11:50:36 +0000 (12:50 +0100)] 
Coments and debug tracing only

See Trac #15205

17 months agoRefactor the kind-checking of tyvar binders
Simon Peyton Jones [Mon, 25 Jun 2018 12:20:59 +0000 (13:20 +0100)] 
Refactor the kind-checking of tyvar binders

The refactoring here is driven by the ghastly mess described in
comment:24 of Trac #1520.  The overall goal is to simplify the
kind-checking of typev-variable binders, and in particular to narrow
the use of the "in-scope tyvar binder" stuff,
which is needed only for associated types: see the new
Note [Kind-checking tyvar binders for associated types] in TcHsType.


* The "in-scope tyvar binder" stuff is done only in
     - kcLHsQTyVars, which is used for the LHsQTyVars of a
       data/newtype, or type family declaration.

     - tcFamTyPats, which is used for associated family instances;
       it now calls tcImplicitQTKBndrs, which in turn usese

* tcExpicitTKBndrs (which is used only for function signatures,
  data con signatures, pattern synonym signatures, and expression
  type signatures) now does not go via the "in-scope tyvar binder"
  stuff at all.

While I'm still not happy with all this code, the code is generally
simpler, and I think this is a useful step forward. It does cure
the problem too.

(It's hard to trigger the problem in vanilla Haskell code, because
the renamer would normally use different names for nested binders,
so I can't offer a test.)

17 months agoImprove tc-tracing a bit
Simon Peyton Jones [Mon, 25 Jun 2018 10:46:29 +0000 (11:46 +0100)] 
Improve tc-tracing a bit

17 months agoFix error recovery for pattern synonyms
Simon Peyton Jones [Mon, 25 Jun 2018 10:42:46 +0000 (11:42 +0100)] 
Fix error recovery for pattern synonyms

As Trac #15289 showed, we were carrying on after a type error
in a pattern synonym, and then crashing.  This patch improves
error handling for pattern synonyms.

I also moved a bit of code from TcBinds into TcPatSyn, which
helpfully narrows the API.

17 months agoTweak API Annotations for ConDeclGADT
Alan Zimmerman [Sun, 24 Jun 2018 20:00:22 +0000 (22:00 +0200)] 
Tweak API Annotations for ConDeclGADT

17 months agoRemove -Wamp flag
roland [Thu, 21 Jun 2018 21:01:39 +0000 (17:01 -0400)] 
Remove -Wamp flag

Test Plan: "ghc -Wamp XXX.hs"  should give "unrecognised warning flag"

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #11477

Differential Revision:

17 months agorts/linker/{SymbolExtras,elf_got}.c: map code as read-only
Santiago Munín [Thu, 21 Jun 2018 21:00:58 +0000 (17:00 -0400)] 
rts/linker/{SymbolExtras,elf_got}.c: map code as read-only

protect mmaped addresses from writes after being initially manipulated

Test Plan: ./validate

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: angerman, carlostome, rwbarton, thomie, carter

GHC Trac Issues: #14069

Differential Revision:

17 months agorts: Abort if timerfd read fails
Ben Gamari [Thu, 21 Jun 2018 21:00:32 +0000 (17:00 -0400)] 
rts: Abort if timerfd read fails

Currently we belch some output to stderr but fail to abort, resulting in
a busy loop. Fixes #15292.

Test Plan:
 * Validate
 * try running program under environment without timerfd capabilities;
ensure we don't busy-loop

Reviewers: simonmar, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15929

Differential Revision:

17 months agoInclude ghc-heap and libiserv in the "package" file.
HE, Tao [Thu, 21 Jun 2018 21:00:17 +0000 (17:00 -0400)] 
Include ghc-heap and libiserv in the "package" file.

Previously, the `make clean` (as well as `make dist-clean`) doesn't work
for ghc-heap and libiserv, due to these two libraries are not presented
in the "packages" file.

Test Plan: [skip ci]

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agoExplain why opt-cmm is not dumped by ddump-cmm-verbose. [Thu, 21 Jun 2018 20:59:46 +0000 (16:59 -0400)] 
Explain why opt-cmm is not dumped by ddump-cmm-verbose.

We just update the docs to reflect the state of affairs.

opt-cmm is run by the NCG backend so not always run.
ddump-cmm-verbose only dumps passes of the cmm
pipeline so it's not included there. [skip-ci]

Test Plan: doc change

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agoTTG for IPBind had wrong extension name
Alan Zimmerman [Fri, 22 Jun 2018 19:32:19 +0000 (21:32 +0200)] 
TTG for IPBind had wrong extension name

The standard[1] for extension naming is to use the XC prefix for the
internal extension points, rather than for a new constructor.

This is violated for IPBind, having

    data IPBind id
      = IPBind
            (XIPBind id)
            (Either (Located HsIPName) (IdP id))
            (LHsExpr id)
      | XCIPBind (XXIPBind id)

Swap the usage of XIPBind and XCIPBind


Closes #15302

17 months agoMove a Note to the module that refers to it
Simon Peyton Jones [Fri, 22 Jun 2018 12:10:48 +0000 (13:10 +0100)] 
Move a Note to the module that refers to it

17 months agoRemove unnecessary call to checkReductionDepth
Simon Peyton Jones [Fri, 22 Jun 2018 10:30:10 +0000 (11:30 +0100)] 
Remove unnecessary call to checkReductionDepth

We call checkReductionDepth in chooseInstance, so there's no
need to call it in selectNextWorkItem too

17 months agoRefactor try_solve_fromInstance in shortCutSolver
Simon Peyton Jones [Fri, 22 Jun 2018 10:28:37 +0000 (11:28 +0100)] 
Refactor try_solve_fromInstance in shortCutSolver

This patch just removes the CtLoc parameter from trySolveFromInstance,
since it can just as easily (and more uniformly) be gotten from the
CtEvidence it is trying to solve.

17 months agoInstances in no-evidence implications
Simon Peyton Jones [Fri, 22 Jun 2018 10:27:47 +0000 (11:27 +0100)] 
Instances in no-evidence implications

Trac #15290 showed that it's possible that we might attempt to use a
quantified constraint to solve an equality in a situation where we
don't have anywhere to put the evidence bindings.  This made GHC crash.

This patch stops the crash, but still rejects the pogram.  See
Note [Instances in no-evidence implications] in TcInteract.

Finding this bug revealed another lurking bug:

* An infelicity in the treatment of superclasses -- we were expanding
  them locally at the leaves, rather than at their binding site; see
  (3a) in Note [The superclass story].

  As a consequence, TcRnTypes.superclassesMightHelp must look inside

In more detail:

* Stop the crash, by making TcInteract.chooseInstance test for
  the no-evidence-bindings case.  In that case we simply don't
  use the instance.  This entailed a slight change to the type
  of chooseInstance.

* Make TcSMonad.getPendingScDicts (now renamed getPendingGivenScs)
  return only Givens from the /current level/; and make
  TcRnTypes.superClassesMightHelp look inside implications.

* Refactor the simpl_loop and superclass-expansion stuff in
  TcSimplify.  The logic is much easier to understand now, and
  has less duplication.

17 months agoDrop redundant Note
Ryan Scott [Thu, 21 Jun 2018 15:29:53 +0000 (11:29 -0400)] 
Drop redundant Note

Richard added a much better version of this Note in commit
26e9806ada8823160dd63ca2c34556e5848b2f45, so I've decided to point
to that instead.

17 months agoFix incorrect GHC versioning
Herbert Valerio Riedel [Thu, 21 Jun 2018 07:54:50 +0000 (09:54 +0200)] 
Fix incorrect GHC versioning

This is an unstable release, hence it must be x.y.$DATE, rather than x.y.0.$DATE
which would denote a stable pre-release snapshot.

17 months agoconfigure: Set version to 8.7 ghc-8.7-start
Ben Gamari [Wed, 20 Jun 2018 21:11:20 +0000 (17:11 -0400)] 
configure: Set version to 8.7

Bumps haddock submodule.

17 months agocontainers: Bump to
Ben Gamari [Mon, 18 Jun 2018 15:58:43 +0000 (11:58 -0400)] 
containers: Bump to

Bumps containers submodule, among others.

17 months agoFix gcc.exe: error: CreateProcess: No such file or directory
Moritz Angermann [Wed, 20 Jun 2018 03:27:53 +0000 (23:27 -0400)] 
Fix gcc.exe: error: CreateProcess: No such file or directory

When GHC links binaries on windows, we pass a -L and -l flag
to gcc for each dependency in the transitive dependency
closure.  As this will usually overflow the command argument
limit on windows, we use response files to pass all arguments
to gcc.  gcc however internally passes only the -l flags via
a response file to the collect2 command, but puts the -L flags
on the command line. As such if we pass enough -L flags to
gcc--even via a response file--we will eventually overflow the
command line argument length limit due to gcc passing them
to collect2 without resorting to a response file.

To prevent this from happening we move all lirbaries into a
shared temporary folder, and only need to pass a single -L
flag to gcc.  Ideally however this was fixed in gcc.

Reviewers: bgamari, Phyx

Reviewed By: bgamari

Subscribers: erikd, rwbarton, thomie, carter

Differential Revision:

17 months agorts: A bit of cleanup of posix itimer implementation
Ben Gamari [Wed, 20 Jun 2018 03:18:12 +0000 (23:18 -0400)] 
rts: A bit of cleanup of posix itimer implementation

* Use bool instead of HsBool
* Use barf instead of sysErrorBelch; stg_exit

Test Plan: Validate

Reviewers: erikd, simonmar

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agoRemove HsEqTy and XEqTy
Ryan Scott [Wed, 20 Jun 2018 03:17:02 +0000 (23:17 -0400)] 
Remove HsEqTy and XEqTy

After commit d650729f9a0f3b6aa5e6ef2d5fba337f6f70fa60, the
`HsEqTy` constructor of `HsType` is essentially dead code. Given that
we want to remove `HsEqTy` anyway as a part of #10056 (comment:27),
let's just rip it out.

Bumps the haddock submodule.

Test Plan: ./validate

Reviewers: goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #10056

Differential Revision:

17 months agoAllow :info for (~) in GHCi
Ryan Scott [Wed, 20 Jun 2018 03:16:39 +0000 (23:16 -0400)] 
Allow :info for (~) in GHCi

`(~)` is not an identifier according to GHC's parser, which
is why GHCi's `:info` command wouldn't work on it. To rectify this,
we apply the same fix that was put in place for `(->)`: add `(~)` to
GHC's `identifier` parser production.

Test Plan: make test TEST=T10059

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, mpickering, carter

GHC Trac Issues: #10059

Differential Revision:

17 months agoconfigure: Fix libnuma detection logic
Ben Gamari [Wed, 20 Jun 2018 03:16:26 +0000 (23:16 -0400)] 
configure: Fix libnuma detection logic

Test Plan: Validate with numa support

Subscribers: rwbarton, thomie, erikd, carter

Differential Revision:

17 months agoA few more typofixes in docs/comments [ci skip]
Gabor Greif [Wed, 20 Jun 2018 14:00:50 +0000 (16:00 +0200)] 
A few more typofixes in docs/comments [ci skip]

17 months agoRevert "containers: Bump to"
Ben Gamari [Wed, 20 Jun 2018 01:40:55 +0000 (21:40 -0400)] 
Revert "containers: Bump to"

This reverts commit 50e7bff7514ebbd74976c1a9fa0db7a8275178ae.

Reverts submodule changes.

Sigh, the haskeline commit isn't quite upstream yet.

17 months agobase: Add missing instances for Data.Ord.Down
Ben Gamari [Tue, 19 Jun 2018 21:11:05 +0000 (17:11 -0400)] 
base: Add missing instances for Data.Ord.Down


 * MonadFix
 * MonadZip
 * Data
 * Foldable
 * Traversable
 * Eq1
 * Ord1
 * Read1
 * Show1
 * Generic
 * Generic1

Fixes #15098.

Reviewers: RyanGlScott, hvr

Reviewed By: RyanGlScott

Subscribers: sjakobi, rwbarton, thomie, ekmett, carter

GHC Trac Issues: #15098

Differential Revision:

17 months agofindPtr: don't search the nursery
Simon Marlow [Tue, 19 Jun 2018 21:10:55 +0000 (17:10 -0400)] 
findPtr: don't search the nursery

Test Plan: Used it in anger

Reviewers: bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agoTweak wording in documentation
Victor Nawothnig [Tue, 19 Jun 2018 21:10:28 +0000 (17:10 -0400)] 
Tweak wording in documentation

Reviewers: hvr, bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agotestsuite: Add broken test for #15289
Ben Gamari [Mon, 18 Jun 2018 23:10:10 +0000 (19:10 -0400)] 
testsuite: Add broken test for #15289

The stderr output is merely a guess at what we should expect, but currently this
is certainly broken.

17 months agotestsuite: Skip T11627a and T11627b on Darwin
Ben Gamari [Mon, 18 Jun 2018 22:34:07 +0000 (18:34 -0400)] 
testsuite: Skip T11627a and T11627b on Darwin

Darwin tends to give us a very small stack which the retainer profiler tends to
overflow. Strangely, this manifested on CircleCI yet not Harbormaster.

See #15287 and #11627.

17 months agocontainers: Bump to
Ben Gamari [Mon, 18 Jun 2018 15:58:43 +0000 (11:58 -0400)] 
containers: Bump to

Bumps containers submodule, among others.

17 months agotestsuite: Bump metrics for T5631 and T6048
Ben Gamari [Mon, 18 Jun 2018 16:08:15 +0000 (12:08 -0400)] 
testsuite: Bump metrics for T5631 and T6048

It's unclear what these are due to but they are causing the Darwin builds to

17 months agoconfigure: Bump version to 8.6.0
Richard Eisenberg [Tue, 19 Jun 2018 02:36:08 +0000 (22:36 -0400)] 
configure: Bump version to 8.6.0

Bumps haddock submodule.

17 months agoDocument and simplify tcInstTyBinders
Richard Eisenberg [Tue, 19 Jun 2018 02:36:08 +0000 (22:36 -0400)] 
Document and simplify tcInstTyBinders

This fixes #15282.

17 months agoFix API Annotations for GADT constructors
Alan Zimmerman [Mon, 18 Jun 2018 08:18:21 +0000 (10:18 +0200)] 
Fix API Annotations for GADT constructors

This patch completes the work for #14529 by making sure that all API
Annotations end up attached to a SrcSpan that appears in the final

Updates Haddock submodule

Test Plan: ./validate

Reviewers: goldfire, bgamari

Subscribers: rwbarton, thomie, mpickering, carter

GHC Trac Issues: #14529

Differential Revision:

17 months agoAdjust comments (Trac #14164)
Simon Peyton Jones [Tue, 19 Jun 2018 09:43:01 +0000 (10:43 +0100)] 
Adjust comments (Trac #14164)

17 months agoMark some TH tests as req_interp
Ömer Sinan Ağacan [Tue, 19 Jun 2018 07:16:54 +0000 (10:16 +0300)] 
Mark some TH tests as req_interp

- dataToExpQUnit
- qq005
- qq006
- qq007
- qq008
- qq009
- T13949
- T8025

17 months agoFix typo in comment only
Richard Eisenberg [Mon, 18 Jun 2018 15:18:15 +0000 (11:18 -0400)] 
Fix typo in comment only

[skip ci]

17 months agoTypofixes in docs and comments [ci skip]
Gabor Greif [Mon, 18 Jun 2018 12:22:54 +0000 (14:22 +0200)] 
Typofixes in docs and comments [ci skip]

17 months agoFix typechecking of kind signatures
Simon Peyton Jones [Sat, 16 Jun 2018 22:50:02 +0000 (23:50 +0100)] 
Fix typechecking of kind signatures

When typechecking a type like
   Maybe (a :: <kind-sig>)
with a kind signature, we were using tc_lhs_kind to
typecheck the signature.  But that's utterly wrong; we
need the signature to be fully solid (non unresolved
equalities) before using it.  In the case of Trac #14904
we went on to instantiate the kind signature, when it
still had embedded unsolved constraints.  This tripped
the level-checking assertion when unifying a variable.

The fix looks pretty easy to me: just call tcLHsKind
instead.  I had to add KindSigCtxt to

17 months agoTwo small refactorings
Simon Peyton Jones [Sat, 16 Jun 2018 22:30:26 +0000 (23:30 +0100)] 
Two small refactorings

* Define Type.substTyVarBndrs, and use it

* Rename substTyVarBndrCallback to substTyVarBndrUsing,
  and other analogous higher order functions.  I kept
  stumbling over the name.

17 months agoFix an infinite loop in niFixTCvSubst
Simon Peyton Jones [Sat, 16 Jun 2018 22:25:53 +0000 (23:25 +0100)] 
Fix an infinite loop in niFixTCvSubst

Trac #14164 made GHC loop, a pretty serious error. It turned
out that Unify.niFixTCvSubst was looping forever, because we
had a substitution like
    a :-> ....(b :: (c :: d))....
    d :-> ...
We correctly recognised that d was free in the range of the
substitution, but then failed to apply it "deeeply enough"
to the range of the substiuttion, so d was /still/ free in
the range, and we kept on going.

Trac #9106 was caused by a similar problem, but alas my
fix to Trac #9106 was inadequate when the offending type
variable is more deeply buried.  Urk.

This time I think I've fixed it!  It's much more subtle
than I though, and it took most of a long train journey
to figure it out.  I wrote a long note to explain:
Note [Finding the substitution fixpoint]

17 months agoRemove accidentally checked-in T14845.stderr
Ryan Scott [Sun, 17 Jun 2018 19:31:14 +0000 (15:31 -0400)] 
Remove accidentally checked-in T14845.stderr

This was a stderr file for a WIP test in D4728. I ended up removing
the test, but forgot to remove the stderr file.

17 months agoAdd -Werror=compat
Vladislav Zavialov [Sun, 17 Jun 2018 16:51:06 +0000 (12:51 -0400)] 
Add -Werror=compat

Add a flag `-Werror=compat` to GHC which has the effect of `-Werror=x
-Werror=y ...`, where `x, y, ...` are warnings from the `-Wcompat`
option group.

Test Plan: ./validate

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15278

Differential Revision:

17 months agoUse __FILE__ for Cmm assertion locations, fix #8619
Ömer Sinan Ağacan [Sun, 17 Jun 2018 16:50:18 +0000 (12:50 -0400)] 
Use __FILE__ for Cmm assertion locations, fix #8619

It seems like we currently support string literals in Cmm, so we can use
__LINE__ CPP macro in assertion macros. This improves error messages
that previously looked like

    ASSERTION FAILED: file (null), line 1302

(null) part now shows the actual file name.

Also inline some single-use string literals in PrimOps.cmm.

Reviewers: bgamari, simonmar, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agoUNREG: fix CmmRegOff large offset handling on W64 platforms
Sergei Trofimovich [Sun, 17 Jun 2018 16:49:51 +0000 (12:49 -0400)] 
UNREG: fix CmmRegOff large offset handling on W64 platforms

Gabor noticed C warning when building unregisterised
64-bit compiler on GHC.Integer.Types (from integer-simple).

Minimised example with a warning:

{-# LANGUAGE MagicHash #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -Wall #-}

module M (bug) where

import GHC.Prim (Word#, minusWord#, ltWord#)
import GHC.Types (isTrue#)

-- assume Word = Word64
bug :: Word# -> Word#
bug x = if isTrue# (x `ltWord#` 0x8000000000000000##) then 0##
        else x `minusWord#` 0x8000000000000000##

$ LANG=C x86_64-UNREG-linux-gnu-ghc -O1 -c M.hs -fforce-recomp
/tmp/ghc30219_0/ghc_1.hc: In function 'M_bug_entry':

/tmp/ghc30219_0/ghc_1.hc:20:14: error:
     warning: integer constant is so large that it is unsigned

It's caused by limited handling of integer literals in CmmRegOff.
This change switches to use standard integer literal pretty-printer.

C code before the change:

FN_(M_bug_entry) {
W_ _sAg;
_sAg = *Sp;
switch ((W_)(_sAg < 0x8000000000000000UL)) {
case 0x1UL: goto _cAq;
default: goto _cAp;
R1.w = _sAg+-9223372036854775808;
// ...

C code after the change:

FN_(M_bug_entry) {
W_ _sAg;
_sAg = *Sp;
switch ((W_)(_sAg < 0x8000000000000000UL)) {
case 0x1UL: goto _cAq;
default: goto _cAp;
R1.w = _sAg+(-0x8000000000000000UL);

Reported-by: Gabor Greif
Signed-off-by: Sergei Trofimovich <>
Test Plan: test generated code on unregisterised mips64 and amd64

Reviewers: simonmar, ggreif, bgamari

Reviewed By: ggreif, bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agoProvide a better error message for unpromotable data constructor contexts
Ryan Scott [Sun, 17 Jun 2018 16:28:23 +0000 (12:28 -0400)] 
Provide a better error message for unpromotable data constructor contexts

Trac #14845 brought to light a corner case where a data
constructor could not be promoted (even with `-XTypeInType`) due to
an unpromotable constraint in its context. However, the error message
was less than helpful, so this patch adds an additional check to
`tcTyVar` catch unpromotable data constructors like these //before//
they're promoted, and to give a sensible error message in such cases.

Test Plan: make test TEST="T13895 T14845"

Reviewers: simonpj, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #13895, #14845

Differential Revision:

17 months agoImprove documentation of Eq, Ord instances for Float and Double
ARJANEN Loïc Jean David [Sun, 17 Jun 2018 15:30:28 +0000 (11:30 -0400)] 
Improve documentation of Eq, Ord instances for Float and Double

Reviewers: sjakobi, dfeuer, bgamari, hvr

Reviewed By: sjakobi, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15078

Differential Revision:

17 months agoImprove error message when importing an unusable package
Sean D Gillespie [Sun, 17 Jun 2018 15:22:20 +0000 (11:22 -0400)] 
Improve error message when importing an unusable package

If a module cannot be found because it is ignored or from an unusable
package, report this to the user and the reason it is unusable.

Currently, GHC displays the standard "Cannot find module error". For

<no location info>: error:
    Could not find module ‘Control.Monad.Random’
    Perhaps you meant
      Control.Monad.Reader (from mtl-2.2.2)
      Control.Monad.Cont (from mtl-2.2.2)
      Control.Monad.Error (from mtl-2.2.2)

GHC does, however, indicate unusable/ignored packages with the -v flag:

package MonadRandom-0.5.1-1421RgpXdhC8e8UI7D3emA is unusable due to
missing dependencies:

With this change, I took that message and added it to the output of the
"Cannot find module" message.

Reviewers: bgamari, dfeuer

Reviewed By: bgamari

Subscribers: Phyx, dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #4806

Differential Revision:

17 months agoHandle DuplicateRecordFields correctly in filterImports (fixes #14487)
Adam Gundry [Sun, 17 Jun 2018 14:47:57 +0000 (10:47 -0400)] 
Handle DuplicateRecordFields correctly in filterImports (fixes #14487)

filterImports needed a small adjustment to correctly handle record field
definitions arising from modules with DuplicateRecordFields enabled.

Previously hiding fields was not possible with DuplicateRecordFields enabled.

Test Plan: new test rename/should_compile/T14487

Reviewers: bgamari

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #14487

Differential Revision:

17 months agotestsuite: Mark print022 as broken on 32-bit platforms
Ben Gamari [Sun, 17 Jun 2018 14:33:00 +0000 (10:33 -0400)] 
testsuite: Mark print022 as broken on 32-bit platforms

Due to #15061.

17 months agotestsuite: Mark T3001-2 as broken on 32-bit platforms
Ben Gamari [Sun, 17 Jun 2018 14:31:34 +0000 (10:31 -0400)] 
testsuite: Mark T3001-2 as broken on 32-bit platforms

Due to #15063.

17 months agoconfigure: Fail when bootstrapping with GHC 8.2.1
Ben Gamari [Sun, 17 Jun 2018 13:54:18 +0000 (09:54 -0400)] 
configure: Fail when bootstrapping with GHC 8.2.1

See #15281

17 months agoBump process submodule
Ben Gamari [Sun, 17 Jun 2018 12:44:25 +0000 (08:44 -0400)] 
Bump process submodule

17 months agoRevert "rts: Use .cfi_{start|end}proc directives"
Ben Gamari [Sun, 17 Jun 2018 13:41:46 +0000 (09:41 -0400)] 
Revert "rts: Use .cfi_{start|end}proc directives"

This reverts commit 86210b238b86d810874a2315d1715546a4006cea.

17 months agoWarn about implicit kind variables with -Wcompat
Vladislav Zavialov [Sun, 17 Jun 2018 03:44:39 +0000 (23:44 -0400)] 
Warn about implicit kind variables with -Wcompat

According to an accepted proposal

    With -Wcompat, warn if a kind variable is brought into scope
    implicitly in a type with an explicit forall. This applies to type
    signatures and to other contexts that allow a forall with the
    forall-or-nothing rule in effect (for example, class instances).

Test Plan: Validate

Reviewers: goldfire, hvr, bgamari, RyanGlScott

Reviewed By: goldfire

Subscribers: RyanGlScott, rwbarton, thomie, carter

GHC Trac Issues: #15264

Differential Revision:

17 months agobase: Add default implementation for Data.Bits.bitSize
Ben Gamari [Sun, 17 Jun 2018 03:44:03 +0000 (23:44 -0400)] 
base: Add default implementation for Data.Bits.bitSize

Fixes #12970 and will provide a reasonable migration path for the
eventual remove of this function.

Test Plan: Validate

Reviewers: ekmett, hvr

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #12970

Differential Revision:

17 months agoRevert "Amend configure script to support lndir build tree"
Ben Gamari [Sun, 17 Jun 2018 03:31:07 +0000 (23:31 -0400)] 
Revert "Amend configure script to support lndir build tree"

This appears to inexplicably break the OS X build, which fails with:
make[1]: *** No rule to make target `utils/unlit/fs.c', needed by
         `utils/unlit/dist/build/.depend.c_asm'.  Stop.
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

This reverts commit 8ee9c574a6d2105ace858f0fee31750acafe0a0f.

17 months agoEnhanced constant folding
Sylvain Henry [Fri, 13 Apr 2018 17:29:07 +0000 (13:29 -0400)] 
Enhanced constant folding

Until now GHC only supported basic constant folding (lit op lit, expr op
0, etc.).

This patch uses laws of +/-/* (associativity, commutativity,
distributivity) to support some constant folding into nested

Examples of new transformations:

   - simple nesting: (10 + x) + 10 becomes 20 + x
   - deep nesting: 5 + x + (y + (z + (t + 5))) becomes 10 + (x + (y + (z + t)))
   - distribution: (5 + x) * 6 becomes 30 + 6*x
   - simple factorization: 5 + x + (x + (x + (x + 5))) becomes 10 + (4 *x)
   - siblings: (5 + 4*x) - (3*x + 2) becomes 3 + x

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

GHC Trac Issues: #9136

Differential Revision:

(cherry picked from commit fea04defa64871caab6339ff3fc5511a272f37c7)

17 months agocircleci: Add a reference to the documentation on the Wiki
Ben Gamari [Sat, 16 Jun 2018 19:36:09 +0000 (15:36 -0400)] 
circleci: Add a reference to the documentation on the Wiki

17 months agocircleci: Bump fedora docker image tag
Ben Gamari [Sat, 16 Jun 2018 19:21:49 +0000 (15:21 -0400)] 
circleci: Bump fedora docker image tag

17 months agorts: Remove use of __USE_MINGW_ANSI_STDIO
Ben Gamari [Sat, 16 Jun 2018 17:22:31 +0000 (13:22 -0400)] 
rts: Remove use of __USE_MINGW_ANSI_STDIO

As pointed out in #12951, this was a temporary measure to allow GHC to be
bootstrapped on Windows with GHC 7.10. This release is now out of our bootstrap
support window so let's remove it.

17 months agobase: Improve the documentation of the enumFrom series of functions
ARJANEN Loïc Jean David [Sat, 16 Jun 2018 17:00:33 +0000 (13:00 -0400)] 
base: Improve the documentation of the enumFrom series of functions

Fixes #15134.

Reviewers: dfeuer, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15134

Differential Revision:

17 months agoBump nofib submodule
Ben Gamari [Sat, 16 Jun 2018 16:35:16 +0000 (12:35 -0400)] 
Bump nofib submodule

17 months agoPreserve parenthesis in function application in typechecker
Zubin Duggal [Sat, 16 Jun 2018 16:19:43 +0000 (12:19 -0400)] 
Preserve parenthesis in function application in typechecker

Preserve HsPars while typechecking

Test Plan: T15242

Reviewers: bgamari, alanz, simonpj

Reviewed By: alanz, simonpj

Subscribers: simonpj, AndreasK, rwbarton, thomie, carter

GHC Trac Issues: #15242

Differential Revision:

17 months agorts: Use .cfi_{start|end}proc directives
Ben Gamari [Sat, 16 Jun 2018 15:34:28 +0000 (11:34 -0400)] 
rts: Use .cfi_{start|end}proc directives

Test Plan: Validate using LLVM assembler

Reviewers: carter, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #15207

Differential Revision:

17 months agotestsuite: Mark overflow1 as broken on 32-bit platforms due to #15255
Ben Gamari [Sat, 16 Jun 2018 15:33:18 +0000 (11:33 -0400)] 
testsuite: Mark overflow1 as broken on 32-bit platforms due to #15255

Test Plan: Validate on i386

Reviewers: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15255

Differential Revision:

17 months agotestsuite: Mark num009 as broken due to #15062
Ben Gamari [Sat, 16 Jun 2018 15:33:11 +0000 (11:33 -0400)] 
testsuite: Mark num009 as broken due to #15062

Test Plan: Validate

Reviewers: hvr

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15062

Differential Revision:

17 months agoAmend configure script to support lndir build tree
Adam Gundry [Sat, 16 Jun 2018 15:32:55 +0000 (11:32 -0400)] 
Amend configure script to support lndir build tree

Test Plan: ./validate

Reviewers: bgamari

Subscribers: rwbarton, thomie, erikd, carter

GHC Trac Issues: #15257

Differential Revision:

17 months agoQuantify unfixed kind variables in CUSKs
Richard Eisenberg [Thu, 14 Jun 2018 12:50:06 +0000 (08:50 -0400)] 
Quantify unfixed kind variables in CUSKs

This is a small change in user-facing behavior. When we
have a unification variable left over in a CUSK, we previously
would issue an error. But, we can just quantify. This also
teaches kcLHsQTyVars to use quantifyTyVars instead of its own,
ad-hoc quantification scheme.

Fixes #15273.

test case: polykinds/T11648b

17 months agoBuilt-in Natural literals in Core
Sylvain Henry [Fri, 15 Jun 2018 20:23:53 +0000 (16:23 -0400)] 
Built-in Natural literals in Core

Add support for built-in Natural literals in Core.

- Replace MachInt,MachWord, LitInteger, etc. with a single LitNumber
  constructor with a LitNumType field
- Support built-in Natural literals
- Add desugar warning for negative literals
- Move Maybe(..) from GHC.Base to GHC.Maybe for module dependency

This patch introduces only a few rules for Natural literals (compared
to Integer's rules). Factorization of the built-in rules for numeric
literals will be done in another patch as this one is already big to

Test Plan:
  test build with integer-simple

Reviewers: hvr, bgamari, goldfire, Bodigrim, simonmar

Reviewed By: bgamari

Subscribers: phadej, simonpj, RyanGlScott, carter, hsyl20, rwbarton,

GHC Trac Issues: #14170, #14465

Differential Revision:

17 months agoFix #13833: accept type literals with no FlexibleInstances
Kirill Zaborsky [Fri, 15 Jun 2018 18:12:58 +0000 (14:12 -0400)] 
Fix #13833: accept type literals with no FlexibleInstances

Test Plan: ./validate

Reviewers: bgamari, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #13833

Differential Revision:

17 months agoUse data con name instead of parent in lookupRecFieldOcc
Adam Gundry [Fri, 15 Jun 2018 18:11:22 +0000 (14:11 -0400)] 
Use data con name instead of parent in lookupRecFieldOcc

Test Plan: new tests rename/should_compile/{T14747,T15149}

Reviewers: simonpj, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14747, #15149

Differential Revision:

17 months agoMake dtrace enabled GHC work as a bootstrap compiler on FreeBSD
Ben Gamari [Fri, 15 Jun 2018 18:07:51 +0000 (14:07 -0400)] 
Make dtrace enabled GHC work as a bootstrap compiler on FreeBSD

Fixes #15040.

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agoAdd "quantified constraint" context in error message, fix #15231.
HE, Tao [Fri, 15 Jun 2018 17:45:42 +0000 (13:45 -0400)] 
Add "quantified constraint" context in error message, fix #15231.

This patch adds "quantified constraint" context in error message when
UndecidableInstances checking fails for quantified constraints.
See Trac #15231:comment#1.

This patch also pretty-prints the instance head for better error messages.

Test Plan: make test TEST="T15231"

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #15231

Differential Revision:

17 months agoMake NameSort note into proper Note
Matthew Pickering [Fri, 15 Jun 2018 17:45:17 +0000 (13:45 -0400)] 
Make NameSort note into proper Note

Reviewers: adamgundry, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

17 months agoNo Unicode in Parser.y
Vladislav Zavialov [Fri, 15 Jun 2018 17:45:03 +0000 (13:45 -0400)] 
No Unicode in Parser.y

Unicode characters in Parser.y cause build failures
on systems where the locale does not support Unicode.


Test Plan: ./validate

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, mpickering, carter

Differential Revision:

17 months agoBump supported LLVM version to 6.0
Ben Gamari [Fri, 15 Jun 2018 01:37:05 +0000 (21:37 -0400)] 
Bump supported LLVM version to 6.0

This seems to fix a number of segmentation faults.

17 months agotestsuite: Make T4442 compile on i386 and mark as broken
Ben Gamari [Fri, 15 Jun 2018 16:58:59 +0000 (12:58 -0400)] 
testsuite: Make T4442 compile on i386 and mark as broken

There are some rather suspicious failures in the 64-bit case. See #15184 for

17 months agoFix documentation for `-dth-dec-file`
Nathan Collins [Thu, 14 Jun 2018 23:36:23 +0000 (16:36 -0700)] 
Fix documentation for `-dth-dec-file`

The docs said that it took a file argument, as in
`-dth-dec-file=<file>`, but it does not take a file argument!

17 months agocircleci: Remove systemd from Fedora nsswitch configuration
Ben Gamari [Fri, 15 Jun 2018 14:02:06 +0000 (10:02 -0400)] 
circleci: Remove systemd from Fedora nsswitch configuration

Lest we end up with a non-functional user/group lookup, resulting in #15230.

17 months agoMake better "fake tycons" in error recovery
Simon Peyton Jones [Fri, 15 Jun 2018 08:46:30 +0000 (09:46 +0100)] 
Make better "fake tycons" in error recovery

Consider (Trac #15215)
  data T a = MkT ...
  data S a = ...T...MkT....

If there is an error in the definition of 'T' we add a
"fake type constructor" to the type environment, so that we
can continue to typecheck 'S'.  But we /were not/ adding
a fake anything for 'MkT' and so there was an internal
error when we met 'MkT' in the body of 'S'.

The fix is to add fake tycons for all the 'implicits' of 'T'.
This is done by mk_fake_tc in TcTyClsDecls.checkValidTyCl,
which now returns a /list/ of TyCons rather than just one.

On the way I did some refactoring:

* Rename TcTyDecls.tcAddImplicits to tcAddTyConsToGblEnv
  and make it /include/ the TyCons themeselves as well
  as their implicits

* Some incidental refactoring about tcRecSelBinds. The main
  thing is that I've avoided creating a HsValBinds that we
  immediately decompose.  That meant moving some deck chairs

NB: The new error message for the regression test T15215
has the opaque error "Illegal constraint in a type:", flagged
in Trac #14845.  But that's the fault of the latter ticket.
The fix here not to blame.

17 months agoFix corner case in typeKind, plus refactoring
Simon Peyton Jones [Fri, 15 Jun 2018 08:19:55 +0000 (09:19 +0100)] 
Fix corner case in typeKind, plus refactoring

This is a continuation of

    commit 9d600ea68c283b0d38ac663c3cc48baba6b94f57
    Author: Simon Peyton Jones <>
    Date:   Fri Jun 1 16:36:57 2018 +0100

        Expand type synonyms when Linting a forall

That patch pointed out that there was a lurking hole in
typeKind, where it could return an ill-scoped kind, because
of not expanding type synonyms enough.

This patch fixes it, quite nicely

* Use occCheckExpand to expand those synonyms (it was always
  designed for that exact purpose), and call it from

* Consequently, move occCheckExpand from TcUnify.hs to
  Type.hs, and generalise it to take a list of type variables.

I also tidied up lintType a bit.

17 months agoFix the bind-recovery type
Simon Peyton Jones [Fri, 15 Jun 2018 08:08:58 +0000 (09:08 +0100)] 
Fix the bind-recovery type

This patch uses (forall (a::*). a) for the type to
use when recovering from an error in a binding.

Previously (Trac #15276) we had (forall r (a :: TYPE r). a),
which is ill-kinded.

It's quite hard to provoke an error arising from this, because
it only happens in programs that have a type error anyway,
but in a subequent patch I make typeKind fall over if it returns
an ill-scoped kind, and that makes ghci/scripts/T13202 crash
without this fix.

17 months agoUNREG: PprC: add support for of W16 literals (Ticket #15237)
Sergei Trofimovich [Thu, 14 Jun 2018 22:13:16 +0000 (23:13 +0100)] 
UNREG: PprC: add support for of W16 literals (Ticket #15237)

Fix UNREG build failure for 32-bit targets.

This change is an equivalent of commit
("UNREG: PprC: add support for of W32 literals")

The change allows combining two subwords into one word
on 32-bit targets. Tested on nios2-unknown-linux-gnu.

GHC Trac Issues: #15237

Signed-off-by: Sergei Trofimovich <>
17 months agoExclude libraries/libiserv/ and other things via .gitignore.
HE, Tao [Thu, 14 Jun 2018 23:25:37 +0000 (19:25 -0400)] 
Exclude libraries/libiserv/ and other things via .gitignore.

The file is generated by `./boot` and should be excluded from git
via .gitignore, since the file `` may have different line ends on

The file GNUmakefile and dir dist, dist-install should also be excluded
via .gitignore, just as other libraries.

Test Plan: [skip ci]

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: osa1, rwbarton, thomie, carter

Differential Revision:

17 months agoFix broken link
Nathan Collins [Thu, 14 Jun 2018 22:00:22 +0000 (15:00 -0700)] 
Fix broken link


17 months agoBump haddock submodule
Ben Gamari [Thu, 14 Jun 2018 22:06:23 +0000 (18:06 -0400)] 
Bump haddock submodule

17 months agoFix binary and haddock submodule commits
Ben Gamari [Thu, 14 Jun 2018 20:25:21 +0000 (16:25 -0400)] 
Fix binary and haddock submodule commits

17 months agoRevert "rts: Don't keep findPtr symbol alive if not -DDEBUG"
Ben Gamari [Thu, 14 Jun 2018 21:18:29 +0000 (17:18 -0400)] 
Revert "rts: Don't keep findPtr symbol alive if not -DDEBUG"

This reverts commit e4c41ec2b1f2f222c9c8a83ef64d4e566aa47a44. isn't processed by CPP.

17 months agoRevert inadvertant changes to .gitmodules
Ben Gamari [Thu, 14 Jun 2018 19:33:33 +0000 (15:33 -0400)] 
Revert inadvertant changes to .gitmodules