11 months agoDo not pass -DTABLES_NEXT_TO_CODE to gcc (untested) wip/T15548
Joachim Breitner [Wed, 22 Aug 2018 19:58:18 +0000 (12:58 -0700)] 
Do not pass -DTABLES_NEXT_TO_CODE to gcc (untested)

The goal of #15548 is to make GHC itself flexible in whether it should
produce TABLES_NEXT_TO_CODE code or not. Before this patch, it would
statically set the default set of gcc arguments to include
`-DTABLES_NEXT_TO_CODE`. But already the header files set
`-DTABLES_NEXT_TO_CODE`, so maybe this is not needed at all, and can
simply be removed?

11 months agoFound a few more ifdefs in the GHCi code
Joachim Breitner [Tue, 21 Aug 2018 18:36:24 +0000 (11:36 -0700)] 
Found a few more ifdefs in the GHCi code

11 months agoMake tablesNextToCode a proper dynamic flag (#15548)
Joachim Breitner [Tue, 21 Aug 2018 04:29:42 +0000 (21:29 -0700)] 
Make tablesNextToCode a proper dynamic flag (#15548)

There is no more use of the TABLES_NEXT_TO_CODE CPP macro in
`compiler/`. The default value of `tablesNextToCode` is calculated as
before, but now users of the GHCI API can modify this flag.

11 months agoMore note references
Joachim Breitner [Tue, 21 Aug 2018 16:48:33 +0000 (09:48 -0700)] 
More note references

11 months agoAdd a Note and and use integer-wired-in for the unit name
Joachim Breitner [Tue, 21 Aug 2018 16:36:18 +0000 (09:36 -0700)] 
Add a Note and and use integer-wired-in for the unit name

to signpost more clearly that there is something weird going on, and
that people should not look for a package `integer` somewhere. Also,
make sure the name is set only once.

11 months agoUnused import
Joachim Breitner [Tue, 21 Aug 2018 00:28:49 +0000 (17:28 -0700)] 
Unused import

11 months agoUpdate findWiredInPackages to handle new integer unit name
Joachim Breitner [Mon, 20 Aug 2018 23:33:34 +0000 (16:33 -0700)] 
Update findWiredInPackages to handle new integer unit name

The code is more robust now; previously it was assuming in multiple
spots that the wired-in unit name is always equal to the package name;
now this assumption only made in the `matches` function, with
special-case for `integer`.

11 months agoFind the `integer` package (either `integer-gmp` or `integer-simple`)
Joachim Breitner [Mon, 20 Aug 2018 23:00:15 +0000 (16:00 -0700)] 
Find the `integer` package (either `integer-gmp` or `integer-simple`)

11 months agoIntroduce `integerLibrary :: DynFlags -> IntegerLibrary`
Joachim Breitner [Mon, 20 Aug 2018 21:51:44 +0000 (14:51 -0700)] 
Introduce `integerLibrary :: DynFlags -> IntegerLibrary`

which is initialized via `cIntegerLibraryType`, but can be overriden by
an API user.

The only place where this is used is in `CorePrep`, to decide whether to
use the `S#` constructor.

Also removes the unused `cIntegerLibrary`.

11 months agoUse the same UnitId `integer` for `integer-gmp` and `integer-simple`
Joachim Breitner [Mon, 20 Aug 2018 21:44:23 +0000 (14:44 -0700)] 
Use the same UnitId `integer` for `integer-gmp` and `integer-simple`

this makes more code in GHC independent of the choice of the integer
library, which is beneficial for API users, and is a first step towards
fixing #13477.

11 months agoBump stm submodule
Ben Gamari [Mon, 20 Aug 2018 19:07:12 +0000 (15:07 -0400)] 
Bump stm submodule

11 months agoUpdate .mailmap [skip ci]
Thomas Miedema [Fri, 17 Aug 2018 20:25:05 +0000 (22:25 +0200)] 
Update .mailmap [skip ci]

11 months agoInitialise cec_suppress properly
Simon Peyton Jones [Mon, 20 Aug 2018 14:54:14 +0000 (15:54 +0100)] 
Initialise cec_suppress properly

In TcErrors, cec_suppress is used to suppress low-priority
errors in favour of truly insoluble ones.

But I was failing to initialise it correcly at top level, which
resulted in Trac #15539.  Easy to fix.

A few regression tests have fewer errors reported, but that seems to
be an improvement.

11 months agoCSE should deal with letrec (#9441)
roland [Sat, 18 Aug 2018 21:45:31 +0000 (23:45 +0200)] 
CSE should deal with letrec (#9441)

Summary: Write tests with fewer lines. See comments of nomeata in

Test Plan: make test TESTS='T9441a T9441b T9441c'

Reviewers: nomeata, dfeuer, bgamari

Reviewed By: nomeata

Subscribers: rwbarton, carter

GHC Trac Issues: #9441

Differential Revision:

11 months agoAdd test cases for Ticket #12146.
Aditya [Sat, 9 Jul 2016 06:11:25 +0000 (11:41 +0530)] 
Add test cases for Ticket #12146.

Two tests - a ghci script and a compile fail test have been added.

11 months agoAdd comment explaining change in syntax error suggestion for #12146.
Aditya [Sat, 9 Jul 2016 06:08:38 +0000 (11:38 +0530)] 
Add comment explaining change in syntax error suggestion for #12146.

11 months agoMake ghci work for stage1 and Hadrian
Neil Mitchell [Thu, 9 Aug 2018 12:47:20 +0000 (13:47 +0100)] 
Make ghci work for stage1 and Hadrian

This allows you to use the ghc-in-ghci script in Make even if you
haven't built stage2, and also with Hadrian.  Because of the way -I
works, it will prefer Make/stage2.

11 months agobase: Rewrite semigroup documentation
Tobias Pflug [Fri, 3 Aug 2018 20:52:37 +0000 (22:52 +0200)] 
base: Rewrite semigroup documentation

11 months agobase: rewrite Monoid module docs
Tobias Pflug [Wed, 8 Aug 2018 21:21:02 +0000 (23:21 +0200)] 
base: rewrite Monoid module docs

11 months agoBe mindful of GADT tyvar order when desugaring record updates
Ryan Scott [Fri, 17 Aug 2018 14:31:27 +0000 (16:31 +0200)] 
Be mindful of GADT tyvar order when desugaring record updates

After commit ef26182e2014b0a2a029ae466a4b121bf235e4e4,
the type variable binders in GADT constructor type signatures
are now quantified in toposorted order, instead of always having
all the universals before all the existentials. Unfortunately, that
commit forgot to update some code (which was assuming the latter
scenario) in `DsExpr` which desugars record updates. This wound
up being the cause of #15499.

This patch makes up for lost time by desugaring record updates in
a way such that the desugared expression applies type arguments to
the right-hand side constructor in the correct order—that is, the
order in which they were quantified by the user.

Test Plan: make test TEST=T15499

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15499

Differential Revision:

11 months agoDocument default value of +RTS -N in user's guide
Ömer Sinan Ağacan [Fri, 17 Aug 2018 07:56:28 +0000 (10:56 +0300)] 
Document default value of +RTS -N in user's guide

Summary: (This is documented in `+RTS -?` but wasn't documented in the user's guide)

Reviewers: simonmar, bgamari, monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

Differential Revision:

11 months agoRename SigTv to TyVarTv (#15480)
Joachim Breitner [Fri, 17 Aug 2018 00:16:44 +0000 (17:16 -0700)] 
Rename SigTv to TyVarTv (#15480)

because since #15050, these are no longer used in pattern SIGnatures,
but still in other places where meta-variables should only be unified
with TYpe VARiables.

I also found mentions of `SigTv` in parts of the renamer and desugarer
that do not seem to directly relate to `SigTv` as used in the type
checker, but rather to uses of `forall a.` in type signatures. I renamed
these to `ScopedTv`.

Differential Revision:

11 months agoFix #15527 by pretty-printing an RdrName prefixly
Ryan Scott [Thu, 16 Aug 2018 09:53:33 +0000 (11:53 +0200)] 
Fix #15527 by pretty-printing an RdrName prefixly

When `(.) @Int` is used without enabling `TypeApplications`,
the resulting error message will pretty-print the (symbolic)
`RdrName` `(.)`. However, it does so without parenthesizing it, which
causes the pretty-printed expression to appear as `.@Int`. Yuck.

Since the expression in a type application will always be prefix,
we can fix this issue by using `pprPrefixOcc` instead of plain ol'

Test Plan: make test TEST=T15527

Reviewers: bgamari, monoidal, simonpj

Reviewed By: monoidal, simonpj

Subscribers: rwbarton, carter

GHC Trac Issues: #15527

Differential Revision:

11 months agoprimops: Drop documentation for WORD_SIZE_IN_BITS < 32
Chai T. Rex [Wed, 15 Aug 2018 20:37:55 +0000 (16:37 -0400)] 
primops: Drop documentation for WORD_SIZE_IN_BITS < 32

Removes documentation suggesting that 30 and 31-bit code generation is supported
(in support of

11 months agoCosmetics in GraphColor
Krzysztof Gogolewski [Wed, 15 Aug 2018 16:20:36 +0000 (18:20 +0200)] 
Cosmetics in GraphColor

This allows to run ghc-in-ghci when :set -XTypeApplications is in

11 months agoAdd a test for Trac #15523
Krzysztof Gogolewski [Wed, 15 Aug 2018 14:49:32 +0000 (16:49 +0200)] 
Add a test for Trac #15523

Summary: Fortunately the bug is not present in master.

Test Plan: make test TEST=T15523

Reviewers: bgamari, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: RyanGlScott, rwbarton, carter

GHC Trac Issues: #15523

Differential Revision:

11 months agoprimops: Drop support for WORD_SIZE_IN_BITS < 32
Ben Gamari [Wed, 15 Aug 2018 14:49:26 +0000 (16:49 +0200)] 
primops: Drop support for WORD_SIZE_IN_BITS < 32

Summary: Fixes #15486.

Test Plan: Validate

Reviewers: monoidal

Reviewed By: monoidal

Subscribers: rwbarton, carter

GHC Trac Issues: #15486

Differential Revision:

11 months agoProperly designate LambdaCase alts as CaseAlt in TH
Ryan Scott [Tue, 14 Aug 2018 20:35:23 +0000 (22:35 +0200)] 
Properly designate LambdaCase alts as CaseAlt in TH

When `\case` expressions are parsed normally, their
alternatives are marked as `CaseAlt` (which means that they are
pretty-printed without a `\` character in front of them, unlike for
lambda expressions). However, `\case` expressions created by way of
Template Haskell (in `Convert`) inconsistently designated the case
alternatives as `LambdaExpr`, causing them to be pretty-printed
poorly (as shown in #15518). The fix is simple: use `CaseAlt`

Test Plan: make test TEST=T15518

Reviewers: goldfire, bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15518

Differential Revision:

11 months agoBump parsec submodule
Ben Gamari [Sat, 11 Aug 2018 16:00:44 +0000 (12:00 -0400)] 
Bump parsec submodule

11 months agoSuppress redundant givens during error reporting
Ryan Scott [Sun, 12 Aug 2018 15:27:27 +0000 (17:27 +0200)] 
Suppress redundant givens during error reporting

When GHC reports that it cannot solve a constraint in error
messages, it often reports what given constraints it has in scope.
Unfortunately, sometimes redundant constraints (like `* ~ *`, from
#15361) can sneak in. The fix is simple: blast away these redundant
constraints using `mkMinimalBySCs`.

Test Plan: make test TEST=T15361

Reviewers: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15361

Differential Revision:

11 months agoCheck if files are same in combineSrcSpans
Zubin Duggal [Sun, 12 Aug 2018 13:51:29 +0000 (15:51 +0200)] 
Check if files are same in combineSrcSpans

Summary: If this is not checked, SrcSpans are sometimes mangled by CPP.

Test Plan: ./validate

Reviewers: bgamari, dfeuer

Reviewed By: bgamari

Subscribers: dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #15279

Differential Revision:

11 months ago--show-iface: Qualify all non-local names
Simon Jakobi [Sun, 12 Aug 2018 09:10:39 +0000 (11:10 +0200)] 
--show-iface: Qualify all non-local names

In order to disambiguate names from different modules, qualify all names
that don't originate in the current module.

Also update docs for QueryQualifyName

Test Plan: validate

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter, tdammers

GHC Trac Issues: #15269

Differential Revision:

11 months agouse *test instead of *slowtest for llvm validation on Circle CI
Alp Mestanogullari [Sun, 12 Aug 2018 08:54:30 +0000 (10:54 +0200)] 
use *test instead of *slowtest for llvm validation on Circle CI

Since the LLVM backend is slow enough that *slowtest can't run
in the allocated time on Circle CI, let's just use *test. If that still
doesn't fit in the allocated 5 hours, we can try running just the
compiler tests.

Test Plan: Circle CI validation for LLVM

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

11 months agoCSE should deal with letrec
roland [Sun, 12 Aug 2018 08:24:29 +0000 (10:24 +0200)] 
CSE should deal with letrec

Summary: Add testcase for  #9441

Test Plan: make test TESTS="T9441a T9441b T9441c"

Reviewers: dfeuer, simonpj, thomie, austin, bgamari

Reviewed By: dfeuer

Subscribers: rwbarton, carter

GHC Trac Issues: #9441

Differential Revision:

11 months agoSimplify testsuite driver, part 2
Krzysztof Gogolewski [Sun, 12 Aug 2018 08:09:41 +0000 (10:09 +0200)] 
Simplify testsuite driver, part 2

- Avoid import *; this helps tools such as pyflakes.
The last occurrence in is not easy to remove
as it's used by .T files.
- Use False/True instead of 0/1.

Test Plan: validate

Reviewers: bgamari, thomie, simonmar

Reviewed By: thomie

Subscribers: rwbarton, carter

Differential Revision:

11 months agoSimplify testsuite driver
Krzysztof Gogolewski [Sat, 11 Aug 2018 19:04:04 +0000 (21:04 +0200)] 
Simplify testsuite driver

- remove clean_cmd
- framework_failures was undefined
- times_file was not used
- if_verbose_dump was called only when verbose >= 1; remove the check
- simplify normalise_whitespace

Test Plan: validate

Reviewers: bgamari, thomie

Reviewed By: thomie

Subscribers: rwbarton, carter

Differential Revision:

11 months agoFilter plugin dylib locations
Christiaan Baaij [Sat, 11 Aug 2018 16:56:34 +0000 (18:56 +0200)] 
Filter plugin dylib locations

Previously we just created a cartesian product of the library
paths of the plugin package and the libraries of the package.
Of course, some of these combinations result in a filepath of
a file doesn't exists, leading to #15475.

Instead of making `haskFile` return Nothing in case a file
doesn't exist (which would hide errors), we look at all the
possible dylib locations and ensure that at least one of those
locations is an existing file. If the list turns out to be
empty however, we panic.

Reviewers: mpickering, bgamari

Reviewed By: mpickering

Subscribers: monoidal, rwbarton, carter

GHC Trac Issues: #15475

Differential Revision:

11 months agotestsuite: Bump for unix 2.7
Ben Gamari [Thu, 9 Aug 2018 16:30:43 +0000 (12:30 -0400)] 
testsuite: Bump for unix 2.7

11 months agoBump unix submodule
Ben Gamari [Thu, 9 Aug 2018 15:28:04 +0000 (11:28 -0400)] 
Bump unix submodule

11 months agobase: improve Functor documentation
Tobias Pflug [Fri, 3 Aug 2018 19:17:51 +0000 (21:17 +0200)] 
base: improve Functor documentation

- Rewrite module documentation
- Rewrite class documentation

11 months agoAdd FreeBSD amd64 LLVM target
Viktor Dukhovni [Thu, 9 Aug 2018 05:47:02 +0000 (01:47 -0400)] 
Add FreeBSD amd64 LLVM target

11 months agocircleci: Reduce compression effort to 3
Ben Gamari [Wed, 8 Aug 2018 22:45:53 +0000 (18:45 -0400)] 
circleci: Reduce compression effort to 3

11 months agocircleci: Reduce build verbosity
Ben Gamari [Wed, 8 Aug 2018 19:53:42 +0000 (15:53 -0400)] 
circleci: Reduce build verbosity

11 months agocircleci: Fix documentation building
Ben Gamari [Fri, 3 Aug 2018 20:48:18 +0000 (16:48 -0400)] 
circleci: Fix documentation building

11 months agoRevert "rts: Ensure that the_gc_thread is aligned"
Ben Gamari [Wed, 8 Aug 2018 23:02:03 +0000 (19:02 -0400)] 
Revert "rts: Ensure that the_gc_thread is aligned"

This caused segmentation faults on Darwin.

This reverts commit c6cc93bca69abc258513af8cf2370b14e70fd8fb.

11 months agoAllow arbitrary options to be passed to tar compression
Ben Gamari [Wed, 8 Aug 2018 20:08:02 +0000 (16:08 -0400)] 
Allow arbitrary options to be passed to tar compression

11 months agoYet another Cabal submodule bump
Ben Gamari [Tue, 7 Aug 2018 19:59:22 +0000 (15:59 -0400)] 
Yet another Cabal submodule bump

11 months agotestsuite: Add (broken) test for #15473
Ben Gamari [Tue, 7 Aug 2018 17:59:31 +0000 (13:59 -0400)] 
testsuite: Add (broken) test for #15473

11 months agoBump Cabal submodule
Ben Gamari [Tue, 7 Aug 2018 17:37:13 +0000 (13:37 -0400)] 
Bump Cabal submodule

11 months agoTurn on MonadFail desugaring by default
Herbert Valerio Riedel [Mon, 6 Aug 2018 16:53:06 +0000 (12:53 -0400)] 
Turn on MonadFail desugaring by default

This contains two commits:


Make GHC's code-base compatible w/ `MonadFail`

There were a couple of use-sites which implicitly used pattern-matches
in `do`-notation even though the underlying `Monad` didn't explicitly
support `fail`

This refactoring turns those use-sites into explicit case
discrimations and adds an `MonadFail` instance for `UniqSM`
(`UniqSM` was the worst offender so this has been postponed for a
follow-up refactoring)


Turn on MonadFail desugaring by default

This finally implements the phase scheduled for GHC 8.6 according to

This also preserves some tests that assumed MonadFail desugaring to be
active; all ghc boot libs were already made compatible with this
`MonadFail` long ago, so no changes were needed there.

Test Plan: Locally performed ./validate --fast

Reviewers: bgamari, simonmar, jrtc27, RyanGlScott

Reviewed By: bgamari

Subscribers: bgamari, RyanGlScott, rwbarton, thomie, carter

Differential Revision:

11 months agousers-guide: Enlarge title underlines in 8.8 release notes
Ben Gamari [Mon, 6 Aug 2018 22:54:06 +0000 (18:54 -0400)] 
users-guide: Enlarge title underlines in 8.8 release notes

Somehow the level-2 headings were all missing a tilde, causing Sphinx to complain.

11 months agoBump binary submodule to
Ben Gamari [Mon, 6 Aug 2018 22:39:35 +0000 (18:39 -0400)] 
Bump binary submodule to

This is actually a decrease in the version number since a bump to 0.10
wasn't actually necessary.

11 months agoSupport typechecking of type literals in backpack
Piyush P Kurur [Mon, 6 Aug 2018 22:37:56 +0000 (18:37 -0400)] 
Support typechecking of type literals in backpack

Backpack is unable to type check signatures that expect a data which
is a type level literal. This was reported in issue #15138. These
commits are a fix for this. It also includes a minimal test case that
was mentioned in the issue.

Reviewers: bgamari, ezyang, goldfire

Reviewed By: bgamari, ezyang

Subscribers: simonpj, ezyang, rwbarton, thomie, carter

GHC Trac Issues: #15138

Differential Revision:

11 months agofix timeout related i686 validation issues
Alp Mestanogullari [Mon, 6 Aug 2018 21:53:29 +0000 (17:53 -0400)] 
fix timeout related i686 validation issues

As can be seen on, some
tests are failing on i686 due to too restrictive timeouts. This patch
tweaks those in the hope of solving the 4 failures from that URL due to

Test Plan: ./validate on i686

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

11 months ago[docs] Add missed specialisations warnings to list of those not enabled by -Wall
Maximilian Tagher [Sat, 28 Jul 2018 21:04:16 +0000 (14:04 -0700)] 
[docs] Add missed specialisations warnings to list of those not enabled by -Wall

Enabling `-Weverything` does enable those warnings.

(cherry picked from commit b062bd10a88ea407ae91610f822f0c352909bcce)

11 months agoUnhide GHC.List for haddock
Simon Jakobi [Thu, 19 Jul 2018 12:35:15 +0000 (14:35 +0200)] 
Unhide GHC.List for haddock

The unhidden module GHC.OldList recommends using GHC.List instead.
In consequence we should also have haddocks for GHC.List.

(cherry picked from commit e3df129c8bf4c35693d01ea66238882f3e3b6fe1)

11 months agodocs: Fix wrong module name in hsig example
Mathieu Boespflug [Sat, 21 Jul 2018 11:48:33 +0000 (13:48 +0200)] 
docs: Fix wrong module name in hsig example

In the module signatures section, two modules were defined, `Str` and
`A`, but `A` was importing `Text`, not `Str`.

(cherry picked from commit 26ab3635ca342c88310321d7f310f1c12c23ec4c)

11 months agoAdd since annotation to GHC.ByteOrder
Alexander Biehl [Sun, 5 Aug 2018 10:29:51 +0000 (12:29 +0200)] 
Add since annotation to GHC.ByteOrder

(cherry picked from commit 6fb2620dbc420c976dc9da90b0efc6eae533ebff)

11 months agorts: Ensure that the_gc_thread is aligned
Ben Gamari [Mon, 6 Aug 2018 18:52:59 +0000 (14:52 -0400)] 
rts: Ensure that the_gc_thread is aligned

Since we cast this to a gc_thread the compiler may assume that it's aligned.
Make sure that this is so. Fixes #15482.

11 months agoImprove error message for flags with missing required arguments (#12625)
roland [Mon, 6 Aug 2018 16:50:38 +0000 (12:50 -0400)] 
Improve error message for flags with missing required arguments (#12625)

Test Plan: make TEST=T12625

Reviewers: jstolarek, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #12625

Differential Revision:

11 months agoStop the linker panic
Moritz Angermann [Mon, 6 Aug 2018 16:46:26 +0000 (12:46 -0400)] 
Stop the linker panic

If we fail to initialize the liker properly, we still set the
`initLinkerDone`. In fact we even set that prior to actually
initializing the linker. However if the linker initialization fails, we
the `Done` state is still true. As such we run into the `Dynamic Linker
not initialised` error. Which while technically corret is confusing as
it pulls the attation away from the real issue.

This change puts the Done state into an MVar, and as such ensureing
that all parallel access needs to wait for the linker to be actually
initialized, or try to re-initilize if it fails.

Reviewers: bgamari, RyanGlScott, simonmar, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #9868, #10355, #13137, #13607, #13531

Differential Revision:

11 months agoTestsuite driver: fix encoding issue when calling ghc-pkg
Krzysztof Gogolewski [Mon, 6 Aug 2018 19:38:52 +0000 (21:38 +0200)] 
Testsuite driver: fix encoding issue when calling ghc-pkg

In Python 3, subprocess.communicate() returns a pair of bytes, which
need to be decoded. In, we were just calling str() instead,
which converts b'x' to "b'x'". As a result, the loop that was checking
pkginfo for lines starting with 'library-dirs' couldn't work.

Reviewers: bgamari, thomie, Phyx

Reviewed By: thomie

Subscribers: Phyx, rwbarton, carter

Differential Revision:

11 months agoStrip ../ from testdir (fixes #15469)
Thomas Miedema [Mon, 6 Aug 2018 17:48:39 +0000 (19:48 +0200)] 
Strip ../ from testdir (fixes #15469)

Test Plan: Harbormaster

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, carter

GHC Trac Issues: #15469

Differential Revision:

11 months agoUse -fobject-code in the GHCi script for loading GHC
Michael Sloan [Mon, 6 Aug 2018 17:19:47 +0000 (19:19 +0200)] 
Use -fobject-code in the GHCi script for loading GHC

My very last commit to D4904 removed -fobject-code.  I should have tested this
more thoroughly, because it is required to do a fresh ghci load, as some code
uses unboxed tuples.

One of my motivations for doing this was that if you run the script without
passing -odir / -hidir, it would pollute the source tree with .hi and .o files.
This also appeared to break subsequent builds. I've made it much less likely
that this will happen by instead specifying -odir and -hidir within the ghci
script rather than on the commandline.

I plan to open a separate diff which adds a test that these scripts work.

Until this patch is merged, the workaround is to do `./utils/ghc-in-ghci/ -fobject-code`

Reviewers: bgamari, alpmestan, monoidal

Reviewed By: alpmestan, monoidal

Subscribers: alpmestan, rwbarton, thomie, carter

Differential Revision:

11 months agoMention #15050 in the release notes for 8.8.1
Joachim Breitner [Mon, 6 Aug 2018 13:58:27 +0000 (09:58 -0400)] 
Mention #15050 in the release notes for 8.8.1

11 months agoMove 8.8.1-notes.rst to the right directory
Ryan Scott [Mon, 6 Aug 2018 12:03:18 +0000 (08:03 -0400)] 
Move 8.8.1-notes.rst to the right directory

Somehow, this escaped my notice before.

11 months agoCreate 8.8.1 release notes
Ryan Scott [Mon, 6 Aug 2018 11:49:37 +0000 (07:49 -0400)] 
Create 8.8.1 release notes

I have some pending commits which will debut in GHC 8.8.1,
but we don't yet have release notes for this. This adds them, and
deletes the stale 8.4.1 and 8.4.2 release notes.

Test Plan: Read it

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

11 months agoAllow scoped type variables refer to types
Joachim Breitner [Mon, 6 Aug 2018 00:56:21 +0000 (20:56 -0400)] 
Allow scoped type variables refer to types

This patch implements GHC proposal 29:
(sorry, URL is too long for the commit message linter)
and fixess #15050.

The change is simple: Just use a different meta variable form.

Test suite and documentation updated.

Differential Revision:

11 months agocircleci: Don't build validate-x86_64-linux-debug unregisterised
Ben Gamari [Sun, 5 Aug 2018 20:27:21 +0000 (22:27 +0200)] 
circleci: Don't build validate-x86_64-linux-debug unregisterised

Summary: This was a cut-and-paste error.

Reviewers: alpmestan

Reviewed By: alpmestan

Subscribers: alpmestan, rwbarton, thomie, carter

GHC Trac Issues: #15466

Differential Revision:

11 months agoFix typos
Krzysztof Gogolewski [Sun, 5 Aug 2018 20:13:34 +0000 (22:13 +0200)] 
Fix typos

11 months agoRefactor printMinimalImports (#15439)
vrom911 [Sun, 5 Aug 2018 13:28:25 +0000 (15:28 +0200)] 
Refactor printMinimalImports (#15439)

Split into getMinimalImports and printMinimalImports.
Export both functions from RnNames module.

Reviewers: bgamari, mpickering

Reviewed By: mpickering

Subscribers: mpickering, rwbarton, carter

GHC Trac Issues: #15439

Differential Revision:

11 months agoBump hadrian submodule
Ben Gamari [Sun, 5 Aug 2018 14:27:40 +0000 (10:27 -0400)] 
Bump hadrian submodule

11 months agotestsuite: Bump T3064 expected allocations
Ben Gamari [Sat, 4 Aug 2018 23:08:01 +0000 (19:08 -0400)] 
testsuite: Bump T3064 expected allocations

11 months agoBump filepath submodule
Ben Gamari [Thu, 2 Aug 2018 21:56:30 +0000 (17:56 -0400)] 
Bump filepath submodule

11 months agoBump binary submodule
Ben Gamari [Thu, 2 Aug 2018 12:29:52 +0000 (08:29 -0400)] 
Bump binary submodule

11 months agoBump Cabal submodule
Ben Gamari [Thu, 2 Aug 2018 21:45:00 +0000 (17:45 -0400)] 
Bump Cabal submodule

11 months agoRemove decideKindGeneralisationPlan
Richard Eisenberg [Sat, 14 Jul 2018 20:02:13 +0000 (16:02 -0400)] 
Remove decideKindGeneralisationPlan

TypeInType came with a new function: decideKindGeneralisationPlan.
This type-level counterpart to the term-level decideGeneralisationPlan
chose whether or not a kind should be generalized. The thinking was
that if `let` should not be generalized, then kinds shouldn't either
(under the same circumstances around -XMonoLocalBinds).

However, this is too conservative -- the situation described in the
motivation for "let should be be generalized" does not occur in types.

This commit thus removes decideKindGeneralisationPlan, always

One consequence is that tc_hs_sig_type_and_gen no longer calls
solveEqualities, which reports all unsolved constraints, instead
relying on the solveLocalEqualities in tcImplicitTKBndrs. An effect
of this is that reporing kind errors gets delayed more frequently.
This seems to be a net benefit in error reporting; often, alongside
a kind error, the type error is now reported (and users might find
type errors easier to understand).

Some of these errors ended up at the top level, where it was
discovered that the GlobalRdrEnv containing the definitions in the
local module was not in the TcGblEnv, and thus errors were reported
with qualified names unnecessarily. This commit rejiggers some of
the logic around captureTopConstraints accordingly.

One error message (typecheck/should_fail/T1633)
is a regression, mentioning the name of a default method. However,
that problem is already reported as #10087, its solution is far from
clear, and so I'm not addressing it here.

This commit fixes #15141. As it's an internal refactor, there is
no concrete test case for it.

Along the way, we no longer need the hsib_closed field of
HsImplicitBndrs (it was used only in decideKindGeneralisationPlan)
and so it's been removed, simplifying the datatype structure.

Along the way, I removed code in the validity checker that looks
at coercions. This isn't related to this patch, really (though
it was, at one point), but it's an improvement, so I kept it.

This updates the haddock submodule.

11 months agoRemove obsolete file
Herbert Valerio Riedel [Thu, 2 Aug 2018 13:46:21 +0000 (15:46 +0200)] 
Remove obsolete file

This was missed by 0960a37868e6d08857e86465c8ca346b29b1c813

[skip ci]

11 months agoFix #15415 and simplify tcWildCardBinders
Vladislav Zavialov [Wed, 1 Aug 2018 18:28:16 +0000 (14:28 -0400)] 
Fix #15415 and simplify tcWildCardBinders

Test Plan: Validate

Reviewers: goldfire, simonpj, bgamari

Reviewed By: simonpj

Subscribers: RyanGlScott, rwbarton, thomie, carter

GHC Trac Issues: #15415

Differential Revision:

11 months agoFix #15450 by refactoring checkEmptyCase'
Ryan Scott [Wed, 1 Aug 2018 18:26:44 +0000 (14:26 -0400)] 
Fix #15450 by refactoring checkEmptyCase'

`checkEmptyCase'` (the code path for coverage-checking
`EmptyCase` expressions) had a fair bit of code duplication from the
code path for coverage-checking non-`EmptyCase` expressions, and to
make things worse, it behaved subtly different in some respects (for
instance, emitting different warnings under unsatisfiable
constraints, as shown in #15450). This patch attempts to clean up
both this discrepancy and the code duplication by doing the

* Factor out a `pmInitialTmTyCs` function, which returns the initial
  set of term and type constraints to use when beginning coverage
  checking. If either set of constraints is unsatisfiable, we use an
  empty set in its place so that we can continue to emit as many
  warnings as possible. (The code path for non-`EmptyCase`
  expressions was doing this already, but not the code path for
  `EmptyCase` expressions, which is the root cause of #15450.)

  Along the way, I added a `Note` to explain why we do this.
* Factor out a `pmIsSatisfiable` constraint which checks if a set of
  term and type constraints are satisfiable. This does not change any
  existing behavior; this is just for the sake of deduplicating code.

Test Plan: make test TEST=T15450

Reviewers: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15450

Differential Revision:

11 months agolinker: Nub rpaths
Moritz Angermann [Wed, 1 Aug 2018 18:25:03 +0000 (14:25 -0400)] 
linker: Nub rpaths

When compiling and linking files in `ghci`, we keep adding rpath
arguments to the linker command invoation.  If those are identical we
should `nub` them out.  Otherwise we not only risk overflowing the
argument limit, but also embed huge amounts of identical rpath values
into the dynamic library, eventually leading to the overflow of the load
command size limit, due to the number of rpath entries alone.

A further improvement could be to pass `-Xlinker -dead_strip_dylibs`;
that however might be stipping too aggressively, and potentially lead to
missing symbols?

For the time being I suggest to only do the nubbing and if need be to
provide -Wl,-dead_strip_dylibs when invoking ghci.

Test Plan: ./validate

Reviewers: bgamari, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15446

Differential Revision:

11 months agoPlugin dependency information is stored separately
Christiaan Baaij [Wed, 1 Aug 2018 18:21:22 +0000 (14:21 -0400)] 
Plugin dependency information is stored separately

We need to store the used plugins so that we recompile
a module when a plugin that it uses is recompiled.

However, storing the `ModuleName`s of the plugins used by a
module in the `dep_mods` field made the rest of GHC think
that they belong in the HPT, causing at least the issues
reported in #15234

We therefor store the `ModuleName`s of the plugins in a
new field, `dep_plgins`, which is only used the the
recompilation logic.

Reviewers: mpickering, bgamari

Reviewed By: mpickering, bgamari

Subscribers: alpmestan, rwbarton, thomie, carter

GHC Trac Issues: #15234

Differential Revision:

11 months agoRemove the type-checking knot.
Richard Eisenberg [Tue, 17 Jul 2018 04:12:34 +0000 (00:12 -0400)] 
Remove the type-checking knot.

Bug #15380 hangs because a knot-tied TyCon ended up in a kind.
Looking at the code in tcInferApps, I'm amazed this hasn't happened
before! I couldn't think of a good way to fix it (with dependent
types, we can't really keep types out of kinds, after all), so
I just went ahead and removed the knot.

This was remarkably easy to do. In tcTyVar, when we find a TcTyCon,
just use it. (Previously, we looked up the knot-tied TyCon and used
that.) Then, during the final zonk, replace TcTyCons with the real,
full-blooded TyCons in the global environment. It's all very easy.

The new bit is explained in the existing
Note [Type checking recursive type and class declarations]
in TcTyClsDecls.

Naturally, I removed various references to the knot and the
zonkTcTypeInKnot (and related) functions. Now, we can print types
during type checking with abandon!

NB: There is a teensy error message regression with this patch,
around the ordering of quantified type variables. This ordering
problem is fixed (I believe) with the patch for #14880. The ordering
affects only internal variables that cannot be instantiated with
any kind of visible type application.

There is also a teensy regression around the printing of types
in TH splices. I think this is really a TH bug and will file

Test case: dependent/should_fail/T15380

11 months agoRevert "Don't inline functions with RULES too early"
Ben Gamari [Wed, 1 Aug 2018 10:42:19 +0000 (06:42 -0400)] 
Revert "Don't inline functions with RULES too early"

This commit causes significant performance regressions:
bytes allocated value is too high:
    Expected    T9872d(normal) bytes allocated: 578498120 +/-5%
    Lower bound T9872d(normal) bytes allocated: 549573214
    Upper bound T9872d(normal) bytes allocated: 607423026
    Actual      T9872d(normal) bytes allocated: 677179968
    Deviation   T9872d(normal) bytes allocated:      17.1 %
bytes allocated value is too high:
    Expected    T9872c(normal) bytes allocated: 3096670112 +/-5%
    Lower bound T9872c(normal) bytes allocated: 2941836606
    Upper bound T9872c(normal) bytes allocated: 3251503618
    Actual      T9872c(normal) bytes allocated: 3601872536
    Deviation   T9872c(normal) bytes allocated:       16.3 %
bytes allocated value is too high:
    Expected    T9872b(normal) bytes allocated: 3730686224 +/-5%
    Lower bound T9872b(normal) bytes allocated: 3544151912
    Upper bound T9872b(normal) bytes allocated: 3917220536
    Actual      T9872b(normal) bytes allocated: 4374298272
    Deviation   T9872b(normal) bytes allocated:       17.3 %
bytes allocated value is too high:
    Expected    T9872a(normal) bytes allocated: 2729927408 +/-5%
    Lower bound T9872a(normal) bytes allocated: 2593431037
    Upper bound T9872a(normal) bytes allocated: 2866423779
    Actual      T9872a(normal) bytes allocated: 3225788896
    Deviation   T9872a(normal) bytes allocated:       18.2 %
It's not clear that this was intentional so I'm going to revert for now.

This reverts commit 2110738b280543698407924a16ac92b6d804dc36.

11 months agorts: Fix unused function
Ben Gamari [Wed, 1 Aug 2018 10:15:59 +0000 (06:15 -0400)] 
rts: Fix unused function

11 months agobase: Fix documentation of System.Environment.Blank
Ben Gamari [Tue, 31 Jul 2018 15:34:01 +0000 (11:34 -0400)] 
base: Fix documentation of System.Environment.Blank

This documentation was a bit unprofessional and the markup wasn't

Reviewers: hvr, alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, thomie, carter

Differential Revision:

11 months agousers-guide: Document default +RTS -I value
Ben Gamari [Tue, 31 Jul 2018 15:33:50 +0000 (11:33 -0400)] 
users-guide: Document default +RTS -I value

As mentioned in #15402.

[no ci]

Test Plan: Read it.

Reviewers: alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15402

Differential Revision:

11 months agotestsuite: Add test for #14346
Sylvain Henry [Tue, 31 Jul 2018 15:02:20 +0000 (11:02 -0400)] 
testsuite: Add test for #14346

11 months agoBump Cabal submodule
Ben Gamari [Mon, 30 Jul 2018 23:46:13 +0000 (19:46 -0400)] 
Bump Cabal submodule

11 months agodoc: Fix command for creating a shared library.
Mathieu Boespflug [Sat, 28 Jul 2018 05:33:13 +0000 (07:33 +0200)] 
doc: Fix command for creating a shared library.

The previous command did not work. The `-o` flag was missing.
Moreover, without `-dynamic`, the `-shared` flag will raise obscure
link errors because GHC will try to use static objects when creating
the shared library.

11 months agoEnable two-step allocator on FreeBSD
Ben Gamari [Mon, 30 Jul 2018 22:01:40 +0000 (18:01 -0400)] 
Enable two-step allocator on FreeBSD

Simplify #ifdef nesting and use MAP_GUARD on FreeBSD and similar
systems. This allows the two-step allocator to be used on FreeBSD,
fixing #15348.

11 months agorts: Disable -fkeep-inline-functions due to lack of support on Clang
Ben Gamari [Tue, 31 Jul 2018 00:48:21 +0000 (20:48 -0400)] 
rts: Disable -fkeep-inline-functions due to lack of support on Clang

But keep it as a comment since it is quite useful yet not very discoverable.

11 months agoAdd the paper "Evidence normalisation in System FC"
Simon Peyton Jones [Tue, 31 Jul 2018 12:17:58 +0000 (13:17 +0100)] 
Add the paper "Evidence normalisation in System FC"

This is with a view to editing it to include new developments in
the coerion infrastructure.

11 months agoDon't inline functions with RULES too early
Simon Peyton Jones [Mon, 30 Jul 2018 12:43:56 +0000 (13:43 +0100)] 
Don't inline functions with RULES too early

Trac #15445 showed that a function with an automatically
generated specialisation RULE coudl be inlined before the
RULE had a chance to fire.

This patch attaches a NOINLINE[2] activation to the Id, to
stop this happening.

11 months agobase: Make Foreign.Marshal.Alloc.allocBytes[Aligned] NOINLINE
Ben Gamari [Tue, 24 Oct 2017 16:19:08 +0000 (12:19 -0400)] 
base: Make Foreign.Marshal.Alloc.allocBytes[Aligned] NOINLINE

As noted in #14346, touch# may be optimized away when the simplifier can see
that the continuation passed to allocaBytes will not return. Marking CPS-style
functions with NOINLINE ensures that the simplier can't draw any unsound

Ultimately the right solution here will be to do away with touch# and instead
introduce a scoped primitive as is suggested in #14375.

Note: This was present in 8.2 but was never merged to 8.4 in hopes that
we would have #14375 implemented in time. This meant that the issue
regressed again in 8.4. Thankfully we caught it in time to fix it for

(cherry picked from commit 404bf05ed3193e918875cd2f6c95ae0da5989be2)

11 months agoFix minor formatting issue in users_guide/bugs.rst
Josh Price [Fri, 27 Jul 2018 04:00:31 +0000 (00:00 -0400)] 
Fix minor formatting issue in users_guide/bugs.rst

11 months agoBump terminfo submodule to
Ben Gamari [Fri, 27 Jul 2018 13:57:52 +0000 (09:57 -0400)] 
Bump terminfo submodule to

11 months agoGHC doesn't handle ./ prefixed paths correctly (#12674)
roland [Mon, 30 Jul 2018 20:34:20 +0000 (21:34 +0100)] 
GHC doesn't handle ./ prefixed paths correctly (#12674)

Summary: If a filename starts with a hypen, GHC keeps the prefixed "./" path.

Test Plan: make test TEST=T12674

Reviewers: Phyx, nomeata, bgamari, erikd

Reviewed By: Phyx

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #12674

Differential Revision:

11 months agoFix #15385 by using addDictsDs in matchGuards
Ryan Scott [Mon, 30 Jul 2018 12:47:39 +0000 (08:47 -0400)] 
Fix #15385 by using addDictsDs in matchGuards

When coverage checking pattern-matches, we rely on the call
sites in the desugarer to populate the local dictionaries and term
evidence in scope using `addDictsDs` and `addTmCsDs`. But it turns
out that only the call site for desugaring `case` expressions was
actually doing this properly. In another part of the desugarer,
`matchGuards` (which handles pattern guards), it did not update the
local dictionaries in scope at all, leading to #15385.

Fixing this is relatively straightforward: just augment the
`BindStmt` case of `matchGuards` to use `addDictsDs` and `addTmCsDs`.
Accomplishing this took a little bit of import/export tweaking:

* We now need to export `collectEvVarsPat` from `HsPat.hs`.
* To avoid an import cycle with `Check.hs`, I moved `isTrueLHsExpr`
  from `DsGRHSs.hs` to `DsUtils.hs`, which resides lower on the
  import chain.

Test Plan: make test TEST=T15385

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15385

Differential Revision:

11 months agoFix #15453: bug in ForAllCo case in opt_trans_rule
Ningning Xie [Sun, 29 Jul 2018 11:15:33 +0000 (13:15 +0200)] 
Fix #15453: bug in ForAllCo case in opt_trans_rule


co1 = \/ tv1 : eta1. r1
co2 = \/ tv2 : eta2. r2

We would like to optimize `co1; co2` so we push transitivity inside forall.
It should be

\/tv1 : (eta1;eta2).  (r1; r2[tv2 |-> tv1 |> eta1])

It is implemented in the ForAllCo case in opt_trans_rule in OptCoercion.
However current implementation is not right:

r2' = substCoWithUnchecked [tv2] [TyVarTy tv1] r2 -- ill-kinded!

This patch corrects it to be

r2' = substCoWithUnchecked [tv2] [mkCastTy (TyVarTy tv1) eta1] r2

Test Plan: validate

Reviewers: bgamari, goldfire, RyanGlScott

Reviewed By: RyanGlScott

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #15453

Differential Revision: