23 months agodisable the nullary constr subst for now wip/cross-constr-cse
Gabor Greif [Mon, 31 Jul 2017 07:13:10 +0000 (09:13 +0200)] 
disable the nullary constr subst for now

23 months agobetter comment out some lines that gen warnings
Gabor Greif [Sun, 30 Jul 2017 16:15:19 +0000 (18:15 +0200)] 
better comment out some lines that gen warnings

23 months agosuppress some warnings for now and enable the optsn
Gabor Greif [Sun, 30 Jul 2017 15:47:09 +0000 (17:47 +0200)] 
suppress some warnings for now and enable the optsn

23 months agoWIP: debugging
Gabor Greif [Sun, 30 Jul 2017 11:22:28 +0000 (13:22 +0200)] 
WIP: debugging

23 months agomore to fix
Gabor Greif [Sat, 29 Jul 2017 21:05:24 +0000 (23:05 +0200)] 
more to fix

23 months agoclean up
Gabor Greif [Sat, 29 Jul 2017 20:21:53 +0000 (22:21 +0200)] 
clean up

23 months agoAdd T13861
Gabor Greif [Sat, 29 Jul 2017 20:11:01 +0000 (22:11 +0200)] 
Add T13861

23 months agoenable more tests
Gabor Greif [Sat, 29 Jul 2017 15:36:57 +0000 (17:36 +0200)] 
enable more tests

23 months agotest Right -> Just
Gabor Greif [Sat, 29 Jul 2017 14:43:04 +0000 (16:43 +0200)] 
test Right -> Just

23 months agoWIP: first working version
Gabor Greif [Sat, 29 Jul 2017 14:42:37 +0000 (16:42 +0200)] 
WIP: first working version

23 months agoAdd haddock markup
Gabor Greif [Fri, 28 Jul 2017 19:09:03 +0000 (21:09 +0200)] 
Add haddock markup

23 months agoTypofixes [ci skip]
Gabor Greif [Fri, 28 Jul 2017 18:36:59 +0000 (20:36 +0200)] 
Typofixes [ci skip]

23 months agoFollow-up to #13887, for promoted infix constructors
Ryan Scott [Sat, 29 Jul 2017 23:36:42 +0000 (19:36 -0400)] 
Follow-up to #13887, for promoted infix constructors

Correct a couple more spots in the TH pretty-printer by applying the
appropriate parenthesization for infix names. Fixes #13887 (again).

Test Plan: make test TEST=T13887

Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13887

Differential Revision:

23 months agoAdd regression test for #14055
Ryan Scott [Sat, 29 Jul 2017 23:35:52 +0000 (19:35 -0400)] 
Add regression test for #14055

23 months agoFix #14045 by omitting an unnecessary check
Richard Eisenberg [Sat, 29 Jul 2017 01:43:38 +0000 (21:43 -0400)] 
Fix #14045 by omitting an unnecessary check

Previously, we checked the number of patterns in a data instances
for all data families whose kind did not end in a kind variable.
But, of course, undersaturating instances can happen even without
the kind ending in a kind variable. So I've omitted the arity check.
Data families aren't as particular about their arity as type families
are (because data families can be undersaturated). Still, this change
degrades error messages when instances don't have the right arity;
now, instead of reporting a simple mismatch in the number of patterns,
GHC reports kind errors. The new errors are fully accurate, but perhaps
not as easy to work with. Still, with the new flexibility of allowing
data family instances with varying numbers of patterns, I don't see
a better way.

This commit also improves source fidelity in some error messages,
requiring more changes than really are necessary. But without these
changes, error messages around mismatched associated instance heads
were poor.

test cases: indexed-types/should_compile/T14045,

23 months agoAdd '<&>' operator to Data.Functor. '<&>' calls '<$>' with flipped arguments.
Sven Tennie [Fri, 28 Jul 2017 22:25:50 +0000 (18:25 -0400)] 
Add '<&>' operator to Data.Functor. '<&>' calls '<$>' with flipped arguments.

This was proposed by David Feuer
and solves #14029.

The implementation is a copy of the '<&>' operator in Control.Lens.Lens.

Add tests for following Data.Functor operators: '<$>', '<&>', '<$' and '$>'.

'<&>' was added for solving #14029. '<$>', '<$' and '$>' were probably

Reviewers: austin, hvr, bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, rwbarton, thomie

Differential Revision:

23 months agoEnsure that GHC.Stack.callStack doesn't fail
Ben Gamari [Fri, 28 Jul 2017 22:25:35 +0000 (18:25 -0400)] 
Ensure that GHC.Stack.callStack doesn't fail

Test Plan: Validate, ensure the `f7` program of `IPLocation` doesn't

Reviewers: gridaphobe, austin, hvr

Reviewed By: gridaphobe

Subscribers: rwbarton, thomie

GHC Trac Issues: #14028

Differential Revision:

23 months agoAdd rtsopts ignore and ignoreAll.
Andreas Klebinger [Fri, 28 Jul 2017 22:25:24 +0000 (18:25 -0400)] 
Add rtsopts ignore and ignoreAll.

These ignore commandline arguments for ignore and commandline as well as
GHCRTS arguments for ignoreAll. Passing RTS flags given on the command
line along to the program by simply skipping processing of these flags
by the RTS.

This fixes #12870.

Test Plan: ./validate

Reviewers: austin, hvr, bgamari, erikd, simonmar

Reviewed By: simonmar

Subscribers: Phyx, rwbarton, thomie

GHC Trac Issues: #12870

Differential Revision:

23 months agoFix hs-boot knot-tying with record wild cards.
Edward Z. Yang [Fri, 28 Jul 2017 22:25:12 +0000 (18:25 -0400)] 
Fix hs-boot knot-tying with record wild cards.

Fixes #13710.

Signed-off-by: Edward Z. Yang <>
Test Plan: validate

Reviewers: bgamari, austin, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13710

Differential Revision:

23 months agoRemove unnecessary GHC option from SrcLoc
Sven Tennie [Fri, 28 Jul 2017 22:24:34 +0000 (18:24 -0400)] 
Remove unnecessary GHC option from SrcLoc

This was an old workaround for #5252. Fixes #13173.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

23 months agotestsuite: Don't pass allow_abbrev
Ben Gamari [Fri, 28 Jul 2017 22:23:55 +0000 (18:23 -0400)] 
testsuite: Don't pass allow_abbrev

This is only supported by Python 3.5 and later, which is too new for us
to rely on.

Reviewers: austin

Subscribers: rwbarton, thomie, RyanGlScott

GHC Trac Issues: #14050

Differential Revision:

23 months agoEnsure that we always link against libm
Ben Gamari [Fri, 28 Jul 2017 17:41:04 +0000 (13:41 -0400)] 
Ensure that we always link against libm is particularly picky that we declare all of our link
dependencies on Nix. See #14022.

Test Plan: Validate on Nix

Reviewers: austin

Subscribers: hvr, rwbarton, thomie

GHC Trac Issues: #14022

Differential Revision:

23 months agoconfigure: Ensure that user's LD setting is respected
Ben Gamari [Fri, 28 Jul 2017 17:35:01 +0000 (13:35 -0400)] 
configure: Ensure that user's LD setting is respected

This broke in the fix for #13541.

23 months agogitmodules: Delete entry for dead hoopl submodule
Ben Gamari [Fri, 28 Jul 2017 17:32:19 +0000 (13:32 -0400)] 
gitmodules: Delete entry for dead hoopl submodule

23 months agoFix lld detection if both gold and lld are found
Ben Gamari [Fri, 28 Jul 2017 15:48:52 +0000 (11:48 -0400)] 
Fix lld detection if both gold and lld are found

If you have and ld.lld, then will be selected by the
detection logic. This patch prioritizes lld by changing the order. The
rationale for checking lld first is that it's (right now) not part of,
say, a default Linux distro installation and if it's available, it's
very likely that it was installed explicitly and should be seen as a
sign of preference. On FreeBSD LLVM is the (default) base toolchain and
the changed order makes sense there as well, since can be
available in /usr/local via ports/pkg. I don't have access to macOS and
can't say anything about their LLVM toolchain.

At some point we could add a check for LD=ld.lld or as an
optional override to explicitly select a linker.

Since I cannot really remove gcc on Linux, this was the only way to
configure GHC to use ld.lld.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

Tags: PHID-PROJ-5azim3sqhsf7wzvlvaag

Differential Revision:

23 months agoByteCodeGen: use byte indexing for BCenv
Michal Terepeta [Fri, 28 Jul 2017 15:47:28 +0000 (11:47 -0400)] 
ByteCodeGen: use byte indexing for BCenv

This is another change needed for #13825 (also based on D38 by Simon

With the change, we count the stack depth in bytes (instead of words).
We also introduce some `newtype`s to help with the change.

Note that this only changes how `ByteCodeGen` works and shouldn't
affect the generated bytecode.

Signed-off-by: Michal Terepeta <>
Test Plan: ./validate

Reviewers: bgamari, simonmar, austin, hvr

Reviewed By: bgamari, simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #13825

Differential Revision:

23 months agoAdd “BINARY_DIST_DIR” to Makefile
Moritz Angermann [Fri, 28 Jul 2017 15:44:33 +0000 (11:44 -0400)] 
Add “BINARY_DIST_DIR” to Makefile

This allows to customize the location where binary distributions are
placed with `make binary-dist`.

E.g. using:
BINARY_DIST_DIR=/path/to/bindists make binary-dist
will place binary dists outside of the source tree into the given

This change falls back to ".", which is the old behaviour.

Test Plan: build binary-dist

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

23 months agotestsuite: Add test for #14028
Ben Gamari [Fri, 28 Jul 2017 15:44:20 +0000 (11:44 -0400)] 
testsuite: Add test for #14028

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #14028

Differential Revision:

23 months agotestsuite: Produce JUnit output
Ben Gamari [Fri, 28 Jul 2017 15:40:42 +0000 (11:40 -0400)] 
testsuite: Produce JUnit output

Test Plan: Validate, try ingesting into Jenkins.

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13716

Differential Revision:

23 months agoSwitched out optparse for argparse in
Jared Weakly [Thu, 27 Jul 2017 18:33:16 +0000 (14:33 -0400)] 
Switched out optparse for argparse in

Tangentially related to my prior work on trac ticket #12758.

Signed-off-by: Jared Weakly <>
Reviewers: austin, bgamari

Subscribers: rwbarton, thomie

Differential Revision:

23 months agoAdd regression tests for #13601, #13780, #13877
Ryan Scott [Fri, 28 Jul 2017 15:47:38 +0000 (11:47 -0400)] 
Add regression tests for #13601, #13780, #13877

Some recent commits happened to fix other issues:

c2417b87ff59c92fbfa8eceeff2a0d6152b11a47 fixed #13601 and #13780
8e15e3d370e9c253ae0dbb330e25b72cb00cdb76 fixed the original program in #13877

Let's add regression tests for each of these to ensure they stay fixed.

Test Plan: make test TEST="T13601 T13780a T13780c T13877"

Reviewers: goldfire, bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13601, #13780, #13877

Differential Revision:

23 months agoMerge types and kinds in DsMeta
Ryan Scott [Fri, 28 Jul 2017 15:35:37 +0000 (11:35 -0400)] 
Merge types and kinds in DsMeta

Types and kinds are now the same in GHC... well, except in the code
that involves Template Haskell, where types and kinds are given separate
treatment. This aims to unify that treatment in the `DsMeta` module.

The gist of this patch is replacing all uses of `repLKind` with `repLTy`.
This is isn't quite as simple as one might imagine, since `repLTy` returns a
`Core (Q Type)` (a monadic expression), whereas `repLKind` returns a
`Core Kind` (a pure expression). This causes many awkward impedance mismatches.

One option would be to change every combinator in `Language.Haskell.TH.Lib` to
take `KindQ` as an argument instead of `Kind`. But this would be a breaking
change of colossal proportions.

Instead, this patch takes a somewhat different approach. This migrates the
existing `Language.Haskell.TH.Lib` module to
`Language.Haskell.TH.Lib.Internal`, and changes all `Kind`-related combinators
in `Language.Haskell.TH.Lib.Internal` to live in `Q`. The new
`Language.Haskell.TH.Lib` module then re-exports most of
`Language.Haskell.TH.Lib.Internal` with the exception of the `Kind`-related
combinators, for which it redefines them to be their current definitions (which
don't live in `Q`). This allows us to retain backwards compatibility with
previous `template-haskell` releases, but more importantly, it allows GHC to
make as many changes to the `Internal` code as it wants for its purposes
without fear of disrupting the public API.

This solves half of #11785 (the other half being `TcSplice`).

Test Plan: ./validate

Reviewers: goldfire, austin, bgamari

Reviewed By: goldfire

Subscribers: rwbarton, thomie

GHC Trac Issues: #11785

Differential Revision:

23 months agoError eagerly after renaming failures in reifyInstances
Ryan Scott [Fri, 28 Jul 2017 15:35:22 +0000 (11:35 -0400)] 
Error eagerly after renaming failures in reifyInstances

Previously, if `reifyInstances` failed to discover a `Name` during
renaming, it would blindy charge into typechecking, at which point GHC would
become very confused at the absence of that `Name` and throw an internal error.
A simple workaround is to fail eagerly after renaming errors.

Test Plan: make test TEST=T13837

Reviewers: goldfire, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13837

Differential Revision:

23 months agoAdd DebugCallStack to piResultTy
Simon Peyton Jones [Fri, 28 Jul 2017 08:29:25 +0000 (09:29 +0100)] 
Add DebugCallStack to piResultTy

This was provoked by an ASSERT failure when debugging #14038,
but it's a godo idea anyway.

23 months agoDo not discard insolubles in implications
Simon Peyton Jones [Thu, 27 Jul 2017 13:52:38 +0000 (14:52 +0100)] 
Do not discard insolubles in implications

Trac #14000 showed up two errors

* In TcRnTypes.dropInsolubles we dropped all implications, which
  might contain the very insolubles we wanted to keep.  This was
  an outright error, and is why the out-of-scope error was actually
  lost altogether in Trac #14000

* In TcSimplify.simplifyInfer, if there are definite (insoluble)
  errors, it's better to suppress the following ambiguity test,
  because the type may be bogus anyway.  See TcSimplify
  Note [Quantification with errors].  This fix seems a bit clunky,
  but it'll do for now.

23 months agoFix ASSERT failure in tc269
Simon Peyton Jones [Thu, 27 Jul 2017 13:47:07 +0000 (14:47 +0100)] 
Fix ASSERT failure in tc269

This ASSERT failure (in substTy) was reported in Trac #14024.

This patch gets the in-scope set right.

(Does not fix tests T13822 or T13594.)

23 months agoRemove redundant constraint in context
Simon Peyton Jones [Thu, 27 Jul 2017 13:46:38 +0000 (14:46 +0100)] 
Remove redundant constraint in context

23 months agoFix instantiation of pattern synonyms
Simon Peyton Jones [Thu, 27 Jul 2017 13:45:54 +0000 (14:45 +0100)] 
Fix instantiation of pattern synonyms

In Check.hs (pattern match ovelap checking) we to figure out the
instantiation of a pattern synonym from the type of the pattern. We
were doing this utterly wrongly.  Trac #13768 demonstrated this

The fix is easy; and is described in PatSyn.hs
  Note [Pattern synonym result type]

23 months agoInitialize hs_init with UTF8 encoded arguments on Windows.
Andreas Klebinger [Thu, 27 Jul 2017 17:16:09 +0000 (18:16 +0100)] 
Initialize hs_init with UTF8 encoded arguments on Windows.

Get utf8 encoded arguments before we call hs_init and use them
instead of ignoring hs_init arguments. This reduces differing
behaviour of the RTS between windows and linux and simplifies
the code involved.

A few testcases were changed to expect the same result on windows
as on linux after the changes.

This fixes #13940.

Test Plan: ./validate

Reviewers: austin, hvr, bgamari, erikd, simonmar, Phyx

Subscribers: Phyx, rwbarton, thomie

GHC Trac Issues: #13940

Differential Revision:

23 months agoRefactor tcInferApps.
Richard Eisenberg [Mon, 24 Jul 2017 19:49:00 +0000 (15:49 -0400)] 
Refactor tcInferApps.

With the changes caused by the fix to #12369, it is now clearer
how to rewrite tcInferApps and friends. This should change no
behavior, but it does clean up a nasty corner of the type checker.
This commit also removes some uses of substTyUnchecked.

23 months agoFix #12369 by being more flexible with data insts
Richard Eisenberg [Wed, 19 Jul 2017 16:28:04 +0000 (12:28 -0400)] 
Fix #12369 by being more flexible with data insts

Previously, a data family's kind had to end in `Type`,
and data instances had to list all the type patterns for the
family. However, both of these restrictions were unnecessary:

- A data family's kind can usefully end in a kind variable `k`.
  See examples on #12369.

- A data instance need not list all patterns, much like how a
  GADT-style data declaration need not list all type parameters,
  when a kind signature is in place. This is useful, for example,

    data family Sing (a :: k)
    data instance Sing :: Bool -> Type where ...

This patch also improved a few error messages, as some error
plumbing had to be moved around.

See new Note [Arity of data families] in FamInstEnv for more

test case: indexed-types/should_compile/T12369

23 months agoFix #12176 by being a bit more careful instantiating.
Richard Eisenberg [Tue, 18 Jul 2017 23:44:17 +0000 (19:44 -0400)] 
Fix #12176 by being a bit more careful instantiating.

Previously, looking up a TyCon that said "no" to mightBeUnsaturated
would then instantiate all of its invisible binders. But this is
wrong for vanilla type synonyms, whose RHS kind might legitimately
start with invisible binders. So a little more care is taken now,
only to instantiate those invisible binders that need to be (so that
the TyCon isn't unsaturated).

23 months agoDocument that type holes kill polymorphic recursion
Richard Eisenberg [Tue, 18 Jul 2017 19:55:21 +0000 (15:55 -0400)] 
Document that type holes kill polymorphic recursion

This "fixes" #11995.

23 months agoFix #11963 by checking for more mixed type/kinds
Richard Eisenberg [Tue, 18 Jul 2017 19:49:38 +0000 (15:49 -0400)] 
Fix #11963 by checking for more mixed type/kinds

This is a straightforward fix -- there were just some omitted

test case: typecheck/should_fail/T11963

23 months agoTrack visibility in TypeEqOrigin
Richard Eisenberg [Tue, 18 Jul 2017 18:30:40 +0000 (14:30 -0400)] 
Track visibility in TypeEqOrigin

A type equality error can arise from a mismatch between
*invisible* arguments just as easily as from visible arguments.
But we should really prefer printing out errors from visible
arguments over invisible ones. Suppose we have a mismatch between
`Proxy Int` and `Proxy Maybe`. Would you rather get an error
between `Int` and `Maybe`? Or between `*` and `* -> *`? I thought
so, too.

There is a fair amount of plumbing with this one, but I think
it's worth it.

This commit introduces a performance regression in test
perf/compiler/T5631. The cause of the regression is not the
new visibility stuff, directly: it's due to a change from
zipWithM to zipWith3M in TcUnify. To my surprise, zipWithM
is nicely optimized (it fuses away), but zipWith3M is not.
There are other examples of functions that could be made faster,
so I've posted a separate ticket, #14037, to track these
improvements. For now, I've accepted the small (6.6%) regression.

23 months agoFix #13819 by refactoring TypeEqOrigin.uo_thing
Richard Eisenberg [Wed, 14 Jun 2017 20:35:18 +0000 (16:35 -0400)] 
Fix #13819 by refactoring TypeEqOrigin.uo_thing

The uo_thing field of TypeEqOrigin is used to track the
"thing" (either term or type) that has the type (kind) stored
in the TypeEqOrigin fields. Previously, this was sometimes a
proper Core Type, which needed zonking and tidying. Now, it
is only HsSyn: much simpler, and the error messages now use
the user-written syntax.

But this aspect of uo_thing didn't cause #13819; it was the
sibling field uo_arity that did. uo_arity stored the number
of arguments of uo_thing, useful when reporting something
like "should have written 2 fewer arguments". We wouldn't want
to say that if the thing didn't have two arguments. However,
in practice, GHC was getting this wrong, and this message
didn't seem all that helpful. Furthermore, the calculation
of the number of arguments is what caused #13819 to fall over.
This patch just removes uo_arity. In my opinion, the change
to error messages is a nudge in the right direction.

Test case: typecheck/should_fail/T13819

23 months agoRemove old coercion pretty-printer
Richard Eisenberg [Tue, 6 Jun 2017 15:01:14 +0000 (11:01 -0400)] 
Remove old coercion pretty-printer

Now, all coercions are printed from IfaceType, just like types.

This also changes the rendering of TransCo to use ; instead of
a prefix operator.

23 months agoPreserve CoVar uniques during pretty printing
Richard Eisenberg [Tue, 6 Jun 2017 14:07:16 +0000 (10:07 -0400)] 
Preserve CoVar uniques during pretty printing

Previously, we did this for Types, but not for Coercions.

23 months agoDon't tidy vars when dumping a type
Richard Eisenberg [Fri, 7 Apr 2017 15:13:32 +0000 (11:13 -0400)] 
Don't tidy vars when dumping a type

This makes variables print more consistenty in, say,

23 months agoTest #11672 in typecheck/should_fail/T11672.
Richard Eisenberg [Thu, 1 Jun 2017 22:28:57 +0000 (18:28 -0400)] 
Test #11672 in typecheck/should_fail/T11672.

I believe this was fixed with the fix for #11198.

23 months agoFix #11400, #11560 by documenting an infelicity.
Richard Eisenberg [Thu, 1 Jun 2017 22:09:05 +0000 (18:09 -0400)] 
Fix #11400, #11560 by documenting an infelicity.

Really, the fix for both of these is #11307.

23 months agoImprove error messages around kind mismatches.
Richard Eisenberg [Thu, 1 Jun 2017 21:27:14 +0000 (17:27 -0400)] 
Improve error messages around kind mismatches.

Previously, when canonicalizing (or unifying, in uType) a
heterogeneous equality, we emitted a kind equality and used the
resulting coercion to cast one side of the heterogeneous equality.

While sound, this led to terrible error messages. (See the bugs
listed below.) The problem is that using the coercion built from
the emitted kind equality is a bit like a wanted rewriting a wanted.
The solution is to keep heterogeneous equalities as irreducible.

See Note [Equalities with incompatible kinds] in TcCanonical.

This commit also removes a highly suspicious switch to FM_SubstOnly
when flattening in the kinds of a type variable. I have no idea
why this was there, other than as a holdover from pre-TypeInType.
I've not left a Note because there is simply no reason I can conceive
of that the FM_SubstOnly should be there.

One challenge with this patch is that the emitted derived equalities
might get emitted several times: when a heterogeneous equality is
in an implication and then gets floated out from the implication,
the Derived is present both in and out of the implication. This
causes a duplicate error message. (Test case:
typecheck/should_fail/T7368) Solution: track the provenance of
Derived constraints and refuse to float out a constraint that has
an insoluble Derived.

Lastly, this labels one test (dependent/should_fail/RAE_T32a)
as expect_broken, because the problem is really #12919. The
different handling of constraints in this patch exposes the error.

This fixes bugs #11198, #12373, #13530, and #13610.

test cases:

23 months agoRemove unneeded import
Gabor Greif [Thu, 27 Jul 2017 11:04:21 +0000 (13:04 +0200)] 
Remove unneeded import

23 months agoFix #13968 by consulting isBuiltInOcc_maybe
Ryan Scott [Wed, 26 Jul 2017 21:13:57 +0000 (17:13 -0400)] 
Fix #13968 by consulting isBuiltInOcc_maybe

We were unconditionally reporting `Illegal binding of built-in syntax`
in an error message, but this error doesn't make sense in certain Template
Haskell scenarios which can trigger it. Let's give a more sensible error
message by first checking if the name we're binding really is built-in syntax,
using the handy `isBuiltInOcc_maybe` function.

Test Plan: make test TEST=T13968

Reviewers: bgamari, austin, goldfire

Reviewed By: goldfire

Subscribers: goldfire, rwbarton, thomie

GHC Trac Issues: #13968

Differential Revision:

23 months agoFix note references and some typos
Gabor Greif [Wed, 26 Jul 2017 13:13:04 +0000 (15:13 +0200)] 
Fix note references and some typos

23 months agoTest Trac #14033
Simon Peyton Jones [Wed, 26 Jul 2017 10:30:55 +0000 (11:30 +0100)] 
Test Trac #14033

23 months agoComments only
Simon Peyton Jones [Wed, 26 Jul 2017 07:57:41 +0000 (08:57 +0100)] 
Comments only

23 months agoComments and tc-tracing only
Simon Peyton Jones [Wed, 26 Jul 2017 07:57:16 +0000 (08:57 +0100)] 
Comments and tc-tracing only

23 months agoFix binder visiblity for default methods
Simon Peyton Jones [Wed, 26 Jul 2017 07:51:47 +0000 (08:51 +0100)] 
Fix binder visiblity for default methods

Trac #13998 showed that default methods were getting bogus tyvar
binder visiblity info; and that it matters in the code genreated
by the default-method fill-in mechanism

* The actual fix: in TcTyDecls.mkDefaultMethodType, make TyVarBinders
  with the right visibility info by getting TyConBinders from the
  class TyCon.  (Previously we made up visiblity info, but that
  caused #13998.)

* Define TyCon.tyConTyVarBinders :: [TyConBinder] -> [TyVarBinder]
  which can build correct forall binders for
    a) default methods (Trac #13998)
    b) data constructors
  This was originally BuildTyCl.mkDataConUnivTyVarBinders

* Move mkTyVarBinder, mkTyVarBinders from Type to Var

23 months agoAdd an Outputable instance for ListMap
Simon Peyton Jones [Wed, 26 Jul 2017 07:31:47 +0000 (08:31 +0100)] 
Add an Outputable instance for ListMap

23 months agoFix #10684 by processing deriving clauses with finer grain
Ryan Scott [Tue, 25 Jul 2017 20:14:27 +0000 (16:14 -0400)] 
Fix #10684 by processing deriving clauses with finer grain

Previously, one could experience error cascades with deriving clauses
when one class in a set of many failed to derive, causing the other derived
classes to be skipped entirely and resulting in other errors down the line.
The solution is to process each class in a data type's set of deriving clauses
individually, and engineer it so that failure to derive an individual class
within that set doesn't cancel out the others.

Test Plan: make test TEST="T10684 T12801"

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #10684, #12801

Differential Revision:

23 months agoRevert "Remove unused language pragma"
Matthew Pickering [Tue, 25 Jul 2017 16:08:15 +0000 (17:08 +0100)] 
Revert "Remove unused language pragma"

This reverts commit 7d1909ad110f05c8cb2fb0689ee75857ceb945f6.

It is actually used for Callstacks, woops!

23 months agoRemove unused language pragma
Matthew Pickering [Tue, 25 Jul 2017 15:23:31 +0000 (16:23 +0100)] 
Remove unused language pragma

23 months agoExpose FrontendPluginAction
Matthew Pickering [Tue, 25 Jul 2017 15:22:39 +0000 (16:22 +0100)] 
Expose FrontendPluginAction

It is mentioned in the API but not exported.

23 months agobase: Introduce GHC.ByteOrder
Ben Gamari [Mon, 24 Jul 2017 23:54:37 +0000 (19:54 -0400)] 
base: Introduce GHC.ByteOrder

This provides a ByteOrder type as well as a targetByteOrder value, which
indicates the byte ordering used by the target machine. We might also
consider exposing this via Data.Bits if the CLC is so inclined.

Test Plan: Needs test

Reviewers: hvr, RyanGlScott, austin

Reviewed By: hvr, RyanGlScott

Subscribers: rwbarton, thomie

Differential Revision:

23 months agoFix import error with -XPackageImports when the module has a duplicate name
Eugene Akentyev [Mon, 24 Jul 2017 23:53:57 +0000 (19:53 -0400)] 
Fix import error with -XPackageImports when the module has a duplicate name

Reviewers: austin, bgamari, mpickering

Reviewed By: bgamari

Subscribers: mpickering, rwbarton, thomie

GHC Trac Issues: #13168

Differential Revision:

23 months agotestsuite: Add testcase for #13168
Ben Gamari [Sun, 23 Jul 2017 17:15:22 +0000 (13:15 -0400)] 
testsuite: Add testcase for #13168

Thanks to Ryan Scott for the testcase.

Currently broken.

23 months agoUse libpthread instead of libthr on FreeBSD
Ben Gamari [Mon, 24 Jul 2017 23:02:56 +0000 (19:02 -0400)] 
Use libpthread instead of libthr on FreeBSD

Since #847 we have used libthr due to reported hangs with FreeBSD's
KSE-based M:N pthread implementation. However, this was nearly 12 years
ago and today libpthread seems to work fine. Moreover, adding -lthr to
the linker flags break when used in conjunction with -r when gold is
used (since -l and -r are incompatible although BFD ld doesn't

Test Plan: Validate on FreeBSD

Reviewers: kgardas, austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #847

Differential Revision:

23 months agoDynFlags: Drop rtsBuildTag field
Ben Gamari [Mon, 24 Jul 2017 23:02:20 +0000 (19:02 -0400)] 
DynFlags: Drop rtsBuildTag field

This wasn't used anywhere; the RTS build tag is now constructed in

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision:

23 months agoghc-prim: Don't allocate a thunk for each unpacked UTF-8 character
Ben Gamari [Mon, 24 Jul 2017 23:01:58 +0000 (19:01 -0400)] 
ghc-prim: Don't allocate a thunk for each unpacked UTF-8 character

While debugging #14005 I noticed that unpackCStringUtf8# was allocating
a thunk for each Unicode character that it unpacked. This seems hardly
worthwhile given that the thunk's closure will be at least three words,
whereas the Char itself will be only two and requires only a bit of bit
twiddling to construct.

Test Plan: Validate

Reviewers: simonmar, austin

Subscribers: dfeuer, rwbarton, thomie

Differential Revision:

23 months agousers-guide: Fix URL of deferred type errors paper
Ben Gamari [Mon, 24 Jul 2017 23:01:33 +0000 (19:01 -0400)] 
users-guide: Fix URL of deferred type errors paper

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision:

23 months agousers-guide: Make it easier to reference haddocks
Ben Gamari [Mon, 24 Jul 2017 23:00:24 +0000 (19:00 -0400)] 
users-guide: Make it easier to reference haddocks

Previously you had to painstakingly construct the URI to the haddock
documentation. Now the Python bits have enough smarts to construct this

Reviewers: austin, patrickdoc

Reviewed By: patrickdoc

Subscribers: rwbarton, thomie

Differential Revision:

23 months agousers-guide: Eliminate some redundant index entries
Ben Gamari [Mon, 24 Jul 2017 01:31:47 +0000 (21:31 -0400)] 
users-guide: Eliminate some redundant index entries

23 months agousers-guide: Cross-reference more flags
Ben Gamari [Mon, 24 Jul 2017 01:09:37 +0000 (21:09 -0400)] 
users-guide: Cross-reference more flags

23 months agousers-guides: Fix errant whitespace
Ben Gamari [Sun, 23 Jul 2017 19:48:56 +0000 (15:48 -0400)] 
users-guides: Fix errant whitespace


23 months agoAdd a caveat to the GHC.Generics examples about :+: nesting
Ryan Scott [Mon, 24 Jul 2017 15:54:37 +0000 (11:54 -0400)] 
Add a caveat to the GHC.Generics examples about :+: nesting

GHC's choice in how it nests `:+:` can sometimes affect the
implementaiton of `GHC.Generics`-related code, so we should make a note of
this in the examples we provide. Fixes #9453.

Test Plan: Read it, like it, build it, ship it

Reviewers: bgamari, austin, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #9453

Differential Revision:

23 months agoRemove 8.0.2 release notes file
Ryan Scott [Mon, 24 Jul 2017 15:54:28 +0000 (11:54 -0400)] 
Remove 8.0.2 release notes file

Summary: Some summer cleaning.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

23 months agoFix more documentation wibbles
Ben Gamari [Sun, 23 Jul 2017 18:13:16 +0000 (14:13 -0400)] 
Fix more documentation wibbles

Fixes #14020, #14016, #14015, #14019

23 months agousers-guide: Fix various wibbles
Ben Gamari [Sun, 23 Jul 2017 16:59:49 +0000 (12:59 -0400)] 
users-guide: Fix various wibbles

23 months agousers-guide: Standardize and repair all flag references
Patrick Dougherty [Sun, 23 Jul 2017 16:55:37 +0000 (12:55 -0400)] 
users-guide: Standardize and repair all flag references

This patch does three things:

1.) It simplifies the flag parsing code in `` to properly display
flag definitions created by `.. (ghc|rts)-flag::`. Additionally, all flag
references must include the associated arguments. Documentation has been
added to `editing-guide.rst` to explain this.

2.) It normalizes all flag definitions to a similar format. Notably, all
instances of `<>` have been replaced with `⟨⟩`. All references across the
users guide have been updated to match.

3.) It fixes a couple issues with the flag reference table's generation code,
which did not handle comma separated flags in the same cell and did not
properly reference flags with arguments.

Test Plan:
`SPHINXOPTS = -n` to activate "nitpicky" mode, which reports all broken
references. All remaining errors are references to flags without any

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13980

Differential Revision:

23 months agotestsuite: Fix cabal01 for real this time
Ben Gamari [Fri, 23 Jun 2017 18:47:06 +0000 (14:47 -0400)] 
testsuite: Fix cabal01 for real this time

Somehow the previous version passed on master but fails on ghc-8.2.
Will look deeper later.

(cherry picked from commit a6774e1d70f18f5c05279453d62fb3bcc7f07d7e)

23 months agoghc-prim: Bump version
Ben Gamari [Thu, 20 Jul 2017 15:27:45 +0000 (11:27 -0400)] 
ghc-prim: Bump version

(cherry picked from commit 8c5405f63c2de0c445ec171aab63c35786544b9e)

23 months agoBump integer-gmp version
Ben Gamari [Fri, 21 Jul 2017 21:31:03 +0000 (17:31 -0400)] 
Bump integer-gmp version

(cherry picked from commit 09396ec3bb672e761c3e627484dd02c5a3a76c77)

23 months agoUpdate release notes for 8.2.1
Ben Gamari [Mon, 10 Jul 2017 20:41:42 +0000 (16:41 -0400)] 
Update release notes for 8.2.1

This pulls over changes that were made in the ghc-8.2 branch.

23 months agoBump a bunch of submodules
Ben Gamari [Sun, 23 Jul 2017 15:21:41 +0000 (11:21 -0400)] 
Bump a bunch of submodules

23 months agoPreserve HaskellHaveRTSLinker in bindist
Ben Gamari [Sun, 23 Jul 2017 14:45:07 +0000 (10:45 -0400)] 
Preserve HaskellHaveRTSLinker in bindist

Otherwise you end up with ("target has RTS linker","@HaskellHaveRTSLinker@") in
the installed settings file.

23 months agousers-guide: Improve legibility of OverlappingInstances documentation
Ben Gamari [Sun, 23 Jul 2017 14:44:09 +0000 (10:44 -0400)] 
users-guide: Improve legibility of OverlappingInstances documentation

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision:

23 months agodistrib/configure: Carry FFI include/lib paths from source distribution
Ben Gamari [Sun, 23 Jul 2017 14:43:52 +0000 (10:43 -0400)] 
distrib/configure: Carry FFI include/lib paths from source distribution

`FFILibDir` and `FFIIncludeDir` both show up in the `rts` library's
package registration file.  We therefore must define them or else we'll
end up with spurious `@FFILibDir@` strings in the package registration.

In principle I think we could also take these as arguments to the
bindist configure but this seems simpler and I don't want to verify this
at the moment.

Test Plan: Build bindist while passing `--with-ffi-libraries=...` to
source distribution configure then try to install and use bindist.

Reviewers: austin, hvr

Subscribers: rwbarton, thomie, erikd

Differential Revision:

23 months agoUpdate autoconf scripts
Ben Gamari [Fri, 21 Jul 2017 21:59:22 +0000 (17:59 -0400)] 
Update autoconf scripts

Scripts taken from autoconf 81497f5aaf50a12a9fe0cba30ef18bda46b62959

23 months agoAvoid linear lookup in unload_wkr in the Linker
Bartosz Nitka [Fri, 21 Jul 2017 18:41:41 +0000 (11:41 -0700)] 
Avoid linear lookup in unload_wkr in the Linker

I've encountered an issue with following
reproduction steps:
* `:load` a large number of modules (~2000)
* compile a BCO that depends on many other BCOs from many other modules
* `:reload`
* try to compile anything, even `1` works

Before this patch the last step takes ~5s.
It takes 80ms after.

Test Plan: harbormaster

Reviewers: simonmar, austin, hvr, bgamari

Subscribers: rwbarton, thomie

Differential Revision:

23 months agofix dllwrap issue.
Tamar Christina [Sat, 22 Jul 2017 13:11:07 +0000 (14:11 +0100)] 
fix dllwrap issue.

Summary: Always set dllwrap and windres values.

Reviewers: austin, hvr, bgamari, trofi

Reviewed By: trofi

Subscribers: rwbarton, thomie, erikd

GHC Trac Issues: #13792

Differential Revision:

23 months agoFix ungrammatical error message
Ryan Scott [Sat, 22 Jul 2017 03:08:24 +0000 (23:08 -0400)] 
Fix ungrammatical error message

Test Plan: If it builds, ship it

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision:

23 months agobuild system: Ensure there are no duplicate files in bindist list
Ben Gamari [Fri, 21 Jul 2017 01:39:27 +0000 (21:39 -0400)] 
build system: Ensure there are no duplicate files in bindist list

Several executables inexplicably appear twice in bindist.list, which
ends up producing multiple tar file entries, consequently breaking BSD
tar during extraction. I spent a fair amount of time trying to work out
where these duplicates were coming from to no avail. Since Hadrian is
right around the corner I'm satisfied with a terrible hack: just uniq
bindist.list before producing the bindist tarball.

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13979, #13974

Differential Revision:

23 months agoHsPat: Assume that no spliced patterns are irrefutable
Ben Gamari [Thu, 20 Jul 2017 23:24:00 +0000 (19:24 -0400)] 
HsPat: Assume that no spliced patterns are irrefutable

This is a conservative assumption which will limit some uses of spliced
patterns, but it fixes #13984.

Test Plan: Validate

Reviewers: RyanGlScott, AaronFriel, austin

Reviewed By: RyanGlScott

Subscribers: rwbarton, thomie

GHC Trac Issues: #13984

Differential Revision:

23 months agoRevert "testsuite: Add test for #13916"
Ben Gamari [Thu, 20 Jul 2017 16:06:03 +0000 (12:06 -0400)] 
Revert "testsuite: Add test for #13916"

This reverts commit b2d3ec370b97fe5f448e8f1d4e0b7374c63c60a8. Didn't
mean to push this one.

23 months agotestsuite: Add test for #13916
Ben Gamari [Thu, 20 Jul 2017 15:43:06 +0000 (11:43 -0400)] 
testsuite: Add test for #13916

23 months agodistrib/configure: Canonicalize triples
Ben Gamari [Thu, 20 Jul 2017 15:34:00 +0000 (11:34 -0400)] 
distrib/configure: Canonicalize triples

Previously we failed to do this, which meant that the bindist's
configure would fail when passed --target (as you may need to do when
installing an armv7 bindist on an aarch64 machine, for instance).

Reviewers: hvr, erikd, austin

Reviewed By: hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13934

Differential Revision:

23 months agorts: Claim AP_STACK before adjusting Sp
Ben Gamari [Thu, 20 Jul 2017 15:33:51 +0000 (11:33 -0400)] 
rts: Claim AP_STACK before adjusting Sp

In the fix to #13615 we introduced some logic to atomically blackhole
AP_STACKs closures upon entry. However, this logic was placed *after* a
stack pointer adjustment. This meant that if someone else beat us to
blackholing the AP_STACK we would suspend the thread with uninitialized
content on the stack.  This would then later blow up when threadPaused
attempted to walk the stack, hence #13970.

Silly bug but still cost lots of head-scratching to find.

Thanks to albertov for the great repro.

Fixes #13970. Bug originally introduced by the fix to #13615.

Reviewers: austin, erikd, simonmar

Reviewed By: erikd, simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #13970, #13615

Differential Revision:

23 months agoInterpreter.c: use macros to access/modify Sp
Michal Terepeta [Thu, 20 Jul 2017 15:30:54 +0000 (11:30 -0400)] 
Interpreter.c: use macros to access/modify Sp

This is another step in fixing #13825 (based on D38 by Simon Marlow).

This commit adds a few macros for accessing and modifying `Sp`
(interpreter stack) and will be useful to allow sub-word
indexing/pushing. (but that will be a separate change, this commit
should introduce no changes in behavior)

Signed-off-by: Michal Terepeta <>
Test Plan: ./validate

Reviewers: bgamari, simonmar, austin, erikd

Reviewed By: bgamari, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #13825

Differential Revision:

23 months agoMake IfaceAxiom typechecking lazier.
Edward Z. Yang [Thu, 20 Jul 2017 15:30:46 +0000 (11:30 -0400)] 
Make IfaceAxiom typechecking lazier.

Fixes #13803, but adds a note about a yet to be fixed #13981.

Signed-off-by: Edward Z. Yang <>
Test Plan: validate

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13803

Differential Revision: