ghc.git
20 months agoRemove PostRn / PostTc from HsType, using TTG wip/ttg-2017-10-13
Alan Zimmerman [Sat, 21 Oct 2017 18:22:59 +0000 (20:22 +0200)] 
Remove PostRn / PostTc from HsType, using TTG

And update haddock submodule to match

20 months agoBring in Trees that Grow for HsType
Alan Zimmerman [Sat, 21 Oct 2017 14:18:13 +0000 (16:18 +0200)] 
Bring in Trees that Grow for HsType

And remove HasDefaultX and MonoidX classes

Updates haddock submodule

20 months agoTrees that Grow for HsOverLit
Alan Zimmerman [Wed, 18 Oct 2017 21:26:59 +0000 (23:26 +0200)] 
Trees that Grow for HsOverLit

21 months agoUpdate HsLit for current TTG implementation.
Alan Zimmerman [Tue, 17 Oct 2017 20:55:11 +0000 (22:55 +0200)] 
Update HsLit for current TTG implementation.

21 months agoGet rid of SigPatIn / SigPatOut
Alan Zimmerman [Tue, 17 Oct 2017 15:21:07 +0000 (17:21 +0200)] 
Get rid of SigPatIn / SigPatOut

21 months agoClean up, based on @simonpj feedback
Alan Zimmerman [Tue, 17 Oct 2017 13:01:02 +0000 (15:01 +0200)] 
Clean up, based on @simonpj feedback

Updates haddock submodule

Tests now pass, HsPat fully implemented for TTG.

21 months agoBring in (Unused) NewPat constructor
Alan Zimmerman [Tue, 17 Oct 2017 09:43:56 +0000 (11:43 +0200)] 
Bring in (Unused) NewPat constructor

21 months agoRemove the last PostTc types from HsPat
Alan Zimmerman [Mon, 16 Oct 2017 21:15:04 +0000 (23:15 +0200)] 
Remove the last PostTc types from HsPat

21 months agoMore HsPat TTG in place
Alan Zimmerman [Mon, 16 Oct 2017 15:32:00 +0000 (17:32 +0200)] 
More HsPat TTG in place

21 months agoRemoving more PostTc types
Alan Zimmerman [Mon, 16 Oct 2017 10:40:02 +0000 (12:40 +0200)] 
Removing more PostTc types

21 months agoFully work TTG into ListPat
Alan Zimmerman [Mon, 16 Oct 2017 09:17:46 +0000 (11:17 +0200)] 
Fully work TTG into ListPat

There are now specific variants for each compiler pass

21 months agoGet rid of PostTc type in TuplePat
Alan Zimmerman [Sun, 15 Oct 2017 21:34:42 +0000 (23:34 +0200)] 
Get rid of PostTc type in TuplePat

21 months agoMore HsPats worked in
Alan Zimmerman [Sun, 15 Oct 2017 20:13:55 +0000 (22:13 +0200)] 
More HsPats worked in

But not (yet) as replacements for PostTc / PostRn types

21 months agoValBinds worked through, compiles and expected tests pass
Alan Zimmerman [Sun, 15 Oct 2017 12:09:17 +0000 (14:09 +0200)] 
ValBinds worked through, compiles and expected tests pass

21 months agoWIP on Doing a combined Step 1 and 3 for Trees That Grow
Alan Zimmerman [Sat, 14 Oct 2017 14:00:35 +0000 (16:00 +0200)] 
WIP on Doing a combined Step 1 and 3 for Trees That Grow

21 months agoRe-apply "Typeable: Allow App to match arrow types"
Simon Peyton Jones [Thu, 5 Oct 2017 16:45:20 +0000 (17:45 +0100)] 
Re-apply "Typeable: Allow App to match arrow types"

This re-applies
 commit cc6be3a2f23c9b2e04f9f491099149e1e1d4d20b
  Author: Ben Gamari <bgamari.foss@gmail.com>
  Date:   Tue Sep 19 18:57:38 2017 -0400

    Typeable: Allow App to match arrow types

which was reverted because of Trac #14270.  Now the latter is
fixed we can re-apply it.

The original ticket was Trac #14236

21 months agoDo not bind coercion variables in SpecConstr rules
Simon Peyton Jones [Thu, 12 Oct 2017 10:00:19 +0000 (11:00 +0100)] 
Do not bind coercion variables in SpecConstr rules

Trac #14270 showed that SpecConstr could cause nasty Lint failures
if it generates a RULE that binds coercion varables.  See

 * Note [SpecConstr and casts], and
 * the test simplCore/should_compile/T14270.

This doesn't feel like the final word to me, because somehow the
specialisation "ought" to work.  So I left in a debug WARN to yell if
the new check acutally fires.

Meanwhile, it stops the erroneous specialisation.

binding coercion

21 months agoAdd missing T14325.stderr
Simon Peyton Jones [Thu, 12 Oct 2017 11:45:43 +0000 (12:45 +0100)] 
Add missing T14325.stderr

21 months agoDo not quantify over deriving clauses
Simon Peyton Jones [Thu, 12 Oct 2017 08:25:25 +0000 (09:25 +0100)] 
Do not quantify over deriving clauses

Trac #14331 showed that in a data type decl like

   data D = D deriving (C (a :: k))

we were quantifying D over the 'k' in the deriving clause.  Yikes.

Easily fixed, by deleting code in RnTypes.extractDataDefnKindVars

See the discussion on the ticket, esp comment:8.

21 months agoAdd a missing zonk in TcDerivInfer.simplifyDeriv
Simon Peyton Jones [Wed, 11 Oct 2017 15:17:41 +0000 (16:17 +0100)] 
Add a missing zonk in TcDerivInfer.simplifyDeriv

I'm astonished that anything worked without this!

Fixes Trac #14339

21 months agoAvoid creating dependent types in FloatOut
Simon Peyton Jones [Wed, 11 Oct 2017 13:58:38 +0000 (14:58 +0100)] 
Avoid creating dependent types in FloatOut

This bug was exposed by Trac #14270.  The problem and its cure
is described in SetLevels, Note [Floating and kind casts].

It's simple and will affect very few programs.  But the very
fact that it was so unexpected is discomforting.

21 months agoPretty-printing of derived multi-parameter classes omits parentheses
Alan Zimmerman [Sun, 1 Oct 2017 17:36:03 +0000 (19:36 +0200)] 
Pretty-printing of derived multi-parameter classes omits parentheses

Summary:
Pretty printing a splice with an HsAppType in the deriving clause, such as

    $([d| data Foo a = Foo a deriving (C a) |])

would omit the parens.

Test Plan: ./validate

Reviewers: RyanGlScott, austin, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14289

Differential Revision: https://phabricator.haskell.org/D4056

21 months agoFix #10816 by renaming FixitySigs more consistently
Ryan Scott [Wed, 11 Oct 2017 12:43:37 +0000 (08:43 -0400)] 
Fix #10816 by renaming FixitySigs more consistently

Summary:
#10816 surfaced because we were renaming top-level fixity
declarations with a different code path (`rnSrcFixityDecl`) than
the code path for fixity declarations inside of type classes, which
is not privy to names that exist in the type namespace. Luckily, the
fix is simple: use `rnSrcFixityDecl` in both places.

Test Plan: make test TEST=T10816

Reviewers: austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #10816

Differential Revision: https://phabricator.haskell.org/D4077

21 months agoRemove wc_insol from WantedConstraints
Simon Peyton Jones [Mon, 9 Oct 2017 12:16:59 +0000 (13:16 +0100)] 
Remove wc_insol from WantedConstraints

This patch is a pure refactoring, which I've wanted to do for
some time.  The main payload is

* Remove the wc_insol field from WantedConstraints;
  instead put all the insolubles in wc_simple

* Remove inert_insols from InertCans
  Instead put all the insolubles in inert_irreds

* Add a cc_insol flag to CIrredCan, to record that
  the constraint is definitely insoluble

Reasons

* Quite a bit of code gets slightly simpler
* Fewer concepts to keep separate
* Insolubles don't happen at all in production code that is
  just being recompiled, so previously there was a lot of
  moving-about of empty sets

A couple of error messages acutally improved.

21 months agoDelete two unused functions
Simon Peyton Jones [Mon, 9 Oct 2017 12:18:13 +0000 (13:18 +0100)] 
Delete two unused functions

Delete unused functions
       pprArrowChain
       pprPrefixApp

from TyCoRep

21 months agoChange "cobox" to "co" in debug output
Simon Peyton Jones [Fri, 6 Oct 2017 12:39:54 +0000 (13:39 +0100)] 
Change "cobox" to "co" in debug output

These coercions are /not/ boxed, so "cobox" is positively misleading.
And it's longer than necessary.

21 months agoFix over-eager error suppression in TcErrors
Simon Peyton Jones [Thu, 5 Oct 2017 16:40:28 +0000 (17:40 +0100)] 
Fix over-eager error suppression in TcErrors

See Note [Given insolubles] in TcRnTypes

Fixes Trac #14325.

21 months agoMinor refactoring
Simon Peyton Jones [Thu, 5 Oct 2017 14:02:45 +0000 (15:02 +0100)] 
Minor refactoring

I'm trying to understand Check.hs.  This patch is a very
minor refactoring.  No change in behaviour.

21 months agoTypos in comments only
Simon Peyton Jones [Thu, 5 Oct 2017 14:02:12 +0000 (15:02 +0100)] 
Typos in comments only

21 months agoTidy up some convoluted "child/parent" code
Simon Peyton Jones [Wed, 4 Oct 2017 09:48:10 +0000 (10:48 +0100)] 
Tidy up some convoluted "child/parent" code

In investigating something else (Trac #14307) I encountered the
wonders of TcRnExports.lookupChildrenExport, and the data
type ChildLookupResult.

I managed to remove the NameErr constructor from ChildLookupResult,
and simplify the code significantly at the same time.

This is just refactoring; no change in behaviour.

21 months agoSplit SysTools up some
Tamar Christina [Tue, 10 Oct 2017 18:58:56 +0000 (19:58 +0100)] 
Split SysTools up some

Summary:
SysTools and DriverTools have an annoying mutual dependency.
They also each contain pieces of the linker. In order for
changes to be shared between the library and the exe linking
code this dependency needs to be broken in order to avoid
using hs-boot files.

Reviewers: austin, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4071

21 months agoSimply Data instance context for AmbiguousFieldOcc
Ryan Scott [Sat, 7 Oct 2017 21:59:07 +0000 (17:59 -0400)] 
Simply Data instance context for AmbiguousFieldOcc

The current, verbose instance context can be compacted into
`DataId pass`. Indeed, that's what most of the `Data` instances
in this module already do, so this just makes things consistent.

21 months agoFix #14320 by looking through HsParTy in more places
Ryan Scott [Sat, 7 Oct 2017 20:59:03 +0000 (16:59 -0400)] 
Fix #14320 by looking through HsParTy in more places

Summary:
GHC was needlessly rejecting GADT constructors' type
signatures that were surrounded in parentheses due to the fact that
`splitLHsForAllTy` and `splitLHsQualTy` (which are used to check as
part of checking if GADT constructor return types are correct)
weren't looking through parentheses (i.e., `HsParTy`). This is
easily fixed, though.

Test Plan: make test TEST=T14320

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14320

Differential Revision: https://phabricator.haskell.org/D4072

21 months agoIncorporate changes from #11721 into Template Haskell
Ryan Scott [Sat, 7 Oct 2017 20:58:56 +0000 (16:58 -0400)] 
Incorporate changes from #11721 into Template Haskell

Summary:
#11721 changed the order of type variables in GADT
constructor type signatures, but these changes weren't reflected in
Template Haskell reification of GADTs. Let's do that.

Along the way, I:

* noticed that the `T13885` test was claiming to test TH reification
  of GADTs, but the reified data type wasn't actually a GADT! Since
  this patch touches that part of the codebase, I decided to fix
  this.
* incorporated some feedback from @simonpj in
  https://phabricator.haskell.org/D3687#113566. (These changes alone
  don't account for any different in behavior.)

Test Plan: make test TEST=T11721_TH

Reviewers: goldfire, austin, bgamari, simonpj

Reviewed By: goldfire, bgamari, simonpj

Subscribers: rwbarton, thomie, simonpj

GHC Trac Issues: #11721

Differential Revision: https://phabricator.haskell.org/D4070

21 months agoTestsuite update following d8d87fa
Joachim Breitner [Fri, 6 Oct 2017 14:29:44 +0000 (10:29 -0400)] 
Testsuite update following d8d87fa

21 months agoAdd regression test for #14326
Ryan Scott [Thu, 5 Oct 2017 19:46:05 +0000 (15:46 -0400)] 
Add regression test for #14326

Commit 6b77914cd37b697354611bcd87897885c1e5b4a6 wound up
fixing #14326. Let's add a regression test so that it stays
that way.

21 months agoRemove m_type from Match (#14313)
Joachim Breitner [Wed, 4 Oct 2017 02:09:49 +0000 (22:09 -0400)] 
Remove m_type from Match (#14313)

this is a remains from supporting Result Type Signaturs in the ancient
past.

Differential Revision: https://phabricator.haskell.org/D4066

21 months agoconfigure: Accept *-msys as a Windows OS in a triple
Ben Gamari [Wed, 4 Oct 2017 12:37:26 +0000 (08:37 -0400)] 
configure: Accept *-msys as a Windows OS in a triple

21 months agorts: Print newline after "Stack trace:" on barf
Ben Gamari [Wed, 4 Oct 2017 00:41:17 +0000 (20:41 -0400)] 
rts: Print newline after "Stack trace:" on barf

[skip ci]

21 months agouser-guide: Mention COMPLETE pragma in release notes
Ben Gamari [Tue, 3 Oct 2017 19:09:41 +0000 (15:09 -0400)] 
user-guide: Mention COMPLETE pragma in release notes

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #14305

Differential Revision: https://phabricator.haskell.org/D4059

21 months agobase: Remove deprecated Chan combinators
Ben Gamari [Tue, 3 Oct 2017 19:09:12 +0000 (15:09 -0400)] 
base: Remove deprecated Chan combinators

Removes isEmptyChan and unGetChan, which have been deprecated for a very
long time. See #13561.

Test Plan: Validate

Reviewers: austin, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13561

Differential Revision: https://phabricator.haskell.org/D4060

21 months agoDon't pass HscEnv to functions in the Hsc monad
Douglas Wilson [Tue, 3 Oct 2017 19:08:47 +0000 (15:08 -0400)] 
Don't pass HscEnv to functions in the Hsc monad

`Hsc` is a reader monad in `HscEnv`. Several functions in HscMain were
taking parameters of type `HscEnv` or `DynFlags`, and returning values
of type `Hsc a`. This patch removes those parameters in favour of asking
them from the context.

This removes a source of confusion and should make refactoring a bit
easier.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4061

21 months agoInclude libraries which fill holes as deps when linking.
Edward Z. Yang [Tue, 3 Oct 2017 19:08:24 +0000 (15:08 -0400)] 
Include libraries which fill holes as deps when linking.

Fixes the issue reported at https://github.com/haskell/cabal/issues/4755
and fixes #14304 in the GHC tracker.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: bgamari, austin, goldfire

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14304

Differential Revision: https://phabricator.haskell.org/D4057

21 months agogenapply: Explicitly specify arguments
Moritz Angermann [Tue, 3 Oct 2017 19:06:29 +0000 (15:06 -0400)] 
genapply: Explicitly specify arguments

We seem to not be feeding either live registers or the arguments when
generating the fast call in genapply.  This results in strange signature
missmatches between the callee (expecting no registers) and the call
site, expecting to pass registers.

Test Plan: validate

Reviewers: bgamari, simonmar, austin

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4029

21 months agobase: Add missing @since annotations in GHC.TypeNats
Ben Gamari [Tue, 3 Oct 2017 19:04:16 +0000 (15:04 -0400)] 
base: Add missing @since annotations in GHC.TypeNats

[skip ci]

21 months agoImplement Div, Mod, and Log for type-level nats.
Iavor Diatchki [Tue, 3 Oct 2017 18:58:47 +0000 (14:58 -0400)] 
Implement Div, Mod, and Log for type-level nats.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, dfeuer, adamgundry, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4002

21 months agoTrack the order of user-written tyvars in DataCon
Ryan Scott [Tue, 3 Oct 2017 18:58:27 +0000 (14:58 -0400)] 
Track the order of user-written tyvars in DataCon

After typechecking a data constructor's type signature, its type
variables are partitioned into two distinct groups: the universally
quantified type variables and the existentially quantified type
variables. Then, when prompted for the type of the data constructor,
GHC gives this:

```lang=haskell
MkT :: forall <univs> <exis>. (...)
```

For H98-style datatypes, this is a fine thing to do. But for GADTs,
this can sometimes produce undesired results with respect to
`TypeApplications`. For instance, consider this datatype:

```lang=haskell
data T a where
  MkT :: forall b a. b -> T a
```

Here, the user clearly intended to have `b` be available for visible
type application before `a`. That is, the user would expect
`MkT @Int @Char` to be of type `Int -> T Char`, //not//
`Char -> T Int`. But alas, up until now that was not how GHC
operated—regardless of the order in which the user actually wrote
the tyvars, GHC would give `MkT` the type:

```lang=haskell
MkT :: forall a b. b -> T a
```

Since `a` is universal and `b` is existential. This makes predicting
what order to use for `TypeApplications` quite annoying, as
demonstrated in #11721 and #13848.

This patch cures the problem by tracking more carefully the order in
which a user writes type variables in data constructor type
signatures, either explicitly (with a `forall`) or implicitly
(without a `forall`, in which case the order is inferred). This is
accomplished by adding a new field `dcUserTyVars` to `DataCon`, which
is a subset of `dcUnivTyVars` and `dcExTyVars` that is permuted to
the order in which the user wrote them. For more details, refer to
`Note [DataCon user type variables]` in `DataCon.hs`.

An interesting consequence of this design is that more data
constructors require wrappers. This is because the workers always
expect the first arguments to be the universal tyvars followed by the
existential tyvars, so when the user writes the tyvars in a different
order, a wrapper type is needed to swizzle the tyvars around to match
the order that the worker expects. For more details, refer to
`Note [Data con wrappers and GADT syntax]` in `MkId.hs`.

Test Plan: ./validate

Reviewers: austin, goldfire, bgamari, simonpj

Reviewed By: goldfire, simonpj

Subscribers: ezyang, goldfire, rwbarton, thomie

GHC Trac Issues: #11721, #13848

Differential Revision: https://phabricator.haskell.org/D3687

21 months agoOptimize linker by minimizing calls to tryGCC to avoid fork/exec overhead.
Tamar Christina [Tue, 3 Oct 2017 18:55:28 +0000 (14:55 -0400)] 
Optimize linker by minimizing calls to tryGCC to avoid fork/exec overhead.

On Windows process creations are fairly expensive. As such calling them in
what's essentially a hot loop is also fairly expensive.

Each time we make a call to `tryGCC` the following fork/exec/wait happen

```
gcc -> realgcc -> cc1
```

This is very problematic, because according to the profiler about 20% of the
time is spent on just process creation and spin time.

The goal of the patch is to mitigate this by asking GCC once for it's search
directories, caching these (because it's very hard to change these at all
after the process started since GCC's base dirs don't change unless with
extra supplied `-B` flags.).

We also do the same for the `findSysDll` function, since this computes
the search path every time by registery accesses etc.

These changes and D3909 drop GHC on Windows startup time from 2-3s to 0.5s.

The remaining issue is a 1.5s wait lock on `CONIN$` which can be addressed
with the new I/O manager code. But this makes GHCi as responsive on Windows as
GHC 7.8 was.

Test Plan: ./validate

Reviewers: austin, hvr, bgamari, erikd

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3910

21 months agoAdd ability to produce crash dumps on Windows
Tamar Christina [Tue, 3 Oct 2017 17:37:52 +0000 (13:37 -0400)] 
Add ability to produce crash dumps on Windows

It's often hard to debug things like segfaults on Windows,
mostly because gdb isn't always of use and users don't know
how to effectively use it.

This patch provides a way to create a crash drump by passing

`+RTS --generate-crash-dumps` as an option. If any unhandled
exception is triggered a dump is made that contains enough
information to be able to diagnose things successfully.

Currently the created dumps are a bit big because I include
all registers, code and threads information.

This looks like

```
$ testsuite/tests/rts/derefnull.run/derefnull.exe +RTS
--generate-crash-dumps

Access violation in generated code when reading 0000000000000000
Crash dump created. Dump written to:
        E:\msys64\tmp\ghc-20170901-220250-11216-16628.dmp
```

Test Plan: ./validate

Reviewers: austin, hvr, bgamari, erikd, simonmar

Reviewed By: bgamari, simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3912

21 months agoSync base/changelog.md
Herbert Valerio Riedel [Tue, 3 Oct 2017 18:46:23 +0000 (20:46 +0200)] 
Sync base/changelog.md

This updates the base-4.10.0.0 entry heading which has diverged from

 http://hackage.haskell.org/package/base-4.10.0.0/src/changelog.md

and while at it also sets the GHC version for the base-4.11 entry to
avoid confusion about what GHC 8.2.2's base is going to include.

[skip ci]

21 months agoRevert installing texinfo in CI systems
Joachim Breitner [Tue, 3 Oct 2017 14:42:08 +0000 (10:42 -0400)] 
Revert installing texinfo in CI systems

This reverts commit 00ff02352f07bff7d422e4e48e4e5df9a0b63d83.
This reverts commit 11a59de25d49f999eed0ea55df29d916a66ecd91.

21 months agoAdd regression test for #9725
Ryan Scott [Tue, 3 Oct 2017 14:10:39 +0000 (10:10 -0400)] 
Add regression test for #9725

Kind equalities saves the day!

21 months agoSuppress error cascade in record fields
Simon Peyton Jones [Tue, 3 Oct 2017 13:42:56 +0000 (14:42 +0100)] 
Suppress error cascade in record fields

When a record contruction or pattern uses a data constructor
that isn't in scope, we may produce spurious ambiguous-field
errors (Trac #14307).  E.g.

   f (A { fld = x }) = e

where 'A' is not in scope.  We want to draw attention to the
out-of-scope data constructor first; once that is fixed we
can think about the fields.

This patch suppresses the field errors if the data con is out
of scope.

21 months agoFix nasty bug in w/w for absence analysis
Simon Peyton Jones [Mon, 2 Oct 2017 14:25:02 +0000 (15:25 +0100)] 
Fix nasty bug in w/w for absence analysis

This dark corner was exposed by Trac #14285.  It involves the
interaction between absence analysis and INLINABLE pragmas.

There is a full explanation in Note [aBSENT_ERROR_ID] in MkCore,
which you can read there.  The changes in this patch are

* Make exprIsHNF return True for absentError, treating
  absentError like an honorary data constructor.

* Make absentError /not/ be diverging, unlike other error Ids.

This is all a bit horrible.

* While doing this I found that exprOkForSpeculation didn't
  have a case for value lambdas so I added one.  It's not
  really called on lifted types much, but it seems like the
  right thing

21 months agoMake GHC.IO.Buffer.summaryBuffer strict
Simon Peyton Jones [Mon, 2 Oct 2017 14:28:35 +0000 (15:28 +0100)] 
Make GHC.IO.Buffer.summaryBuffer strict

I came across this when debugging something else.  Making it strict
improves the code slightly without affecting behaviour.

21 months agoFix bug in the short-cut solver
Simon Peyton Jones [Mon, 2 Oct 2017 14:58:46 +0000 (15:58 +0100)] 
Fix bug in the short-cut solver

Trac #13943 showed that the relatively-new short-cut solver
for class constraints (aka -fsolve-constant-dicts) was wrong.
In particular, see "Type families" under Note [Shortcut solving]
in TcInteract.

The short-cut solver recursively solves sub-goals, but it doesn't
flatten type-family applications, and as a result it erroneously
thought that C (F a) cannot possibly match (C 0), which is
simply untrue.  That led to an inifinte loop in the short-cut
solver.

The significant change is the one line

+                 , all isTyFamFree preds  -- See "Type families" in
+                                          -- Note [Shortcut solving]

but, as ever, I do some other refactoring.  (E.g. I changed the
name of the function to shortCutSolver rather than the more
generic trySolveFromInstance.)

I also made the short-cut solver respect the solver-depth limit,
so that if this happens again it won't just produce an infinite
loop.

A bit of other refactoring, notably moving isTyFamFree
from TcValidity to TcType

21 months agoComments only
Simon Peyton Jones [Fri, 29 Sep 2017 10:39:28 +0000 (11:39 +0100)] 
Comments only

21 months agoAdds x86 NONE relocation type
Moritz Angermann [Tue, 3 Oct 2017 01:58:35 +0000 (09:58 +0800)] 
Adds x86 NONE relocation type

Summary:
As reported by Alex Lang, R_X86_64_NONE relocations
appear in per-package object files, not per-module object
files. This diff adds _NONE relocations for x86.

Reviewers: bgamari, geekosaur, austin, erikd, simonmar

Reviewed By: geekosaur

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4062

21 months agoNo libffi docs
Moritz Angermann [Sun, 1 Oct 2017 09:39:28 +0000 (17:39 +0800)] 
No libffi docs

Summary:
building libffi docs with our intree-libffi seems
rather pointless.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4054

21 months agouser-guide: Fix :since: annotation of -pie and add documentation for -fPIE
Ben Gamari [Mon, 2 Oct 2017 22:02:40 +0000 (18:02 -0400)] 
user-guide: Fix :since: annotation of -pie and add documentation for -fPIE

[skip ci]

21 months agoBump libffi-tarballs submodule
Ben Gamari [Mon, 2 Oct 2017 14:47:10 +0000 (10:47 -0400)] 
Bump libffi-tarballs submodule

21 months agorel-notes: Mention libffi packaging change
Ben Gamari [Sat, 30 Sep 2017 16:18:02 +0000 (12:18 -0400)] 
rel-notes: Mention libffi packaging change

[skip ci]

21 months agoRewrite boot in Python
Ben Gamari [Sat, 30 Sep 2017 15:53:16 +0000 (11:53 -0400)] 
Rewrite boot in Python

One step closer to being able to drop the Windows Perl tarball. We
previously attempted to do this in D3567 but were forced to revert due
to Windows problems.

Acknowledgements:
 * @Phyx kindly contributed the codepath allowing this to work on
Windows.

Test Plan: Validate

Reviewers: hvr, austin, Phyx

Subscribers: erikd, thomie, rwbarton

Differential Revision: https://phabricator.haskell.org/D3918

21 months agoPretty-printer missing parens for infix class declaration
Alan Zimmerman [Mon, 2 Oct 2017 16:09:37 +0000 (18:09 +0200)] 
Pretty-printer missing parens for infix class declaration

    class (a `C` b) c

Is pretty printed as

    class a `C` b c

Fixes #14306

21 months agoCircleCI: Install texinfo
Joachim Breitner [Mon, 2 Oct 2017 17:08:12 +0000 (13:08 -0400)] 
CircleCI: Install texinfo

21 months agoTravis: Install texinfo
Joachim Breitner [Mon, 2 Oct 2017 14:55:45 +0000 (10:55 -0400)] 
Travis: Install texinfo

21 months agoBump submodule nofib again (Semigroup now required)
Joachim Breitner [Thu, 14 Sep 2017 20:42:53 +0000 (16:42 -0400)] 
Bump submodule nofib again (Semigroup now required)

Commit 063e0b4e5ea53a02713eb48555bbd99d934a3de5 accidentially undid
7b8827ab24a3af8555f1adf250b7b541e41d8f5d where I bumped nofib
previously.

21 months agoAllow libffi snapshots
Moritz Angermann [Sat, 30 Sep 2017 13:31:12 +0000 (09:31 -0400)] 
Allow libffi snapshots

This is rather annoying. I'd prefer to have a stable release to
use. However libffi-3.2.1 has been released November 12, 2014, and
libffi-4 is TBD. See also https://github.com/libffi/libffi/issues/296

The core reason for this change is that llvm changed the supported
assembly to unified syntax, which libffi-3.2.1 does not use, and hence
fails to compile for arm with llvm. For refence, see the following
issue: https://github.com/libffi/libffi/issues/191.

This diff contains a script to generate a tarball for the
`libffi-tarballs` repository from the libffi GitHub repository; as well
as the necessary changes to the build system.

Updates libffi-tarballs submodule.

Reviewers: austin, bgamari, hvr

Subscribers: hvr, erikd, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3574

21 months agoiserv: Don't build vanilla iserv unless vanilla libraries are built
Ben Gamari [Sat, 30 Sep 2017 03:33:29 +0000 (23:33 -0400)] 
iserv: Don't build vanilla iserv unless vanilla libraries are built

Test Plan: Validate

Reviewers: austin, snowleopard

Subscribers: angerman, rwbarton, thomie, int-e

Differential Revision: https://phabricator.haskell.org/D4042

21 months agoDon't use "character" in haddocks of Char
Ben Gamari [Sat, 30 Sep 2017 03:33:03 +0000 (23:33 -0400)] 
Don't use "character" in haddocks of Char

Character is a terribly overloaded term and may refer to graphemes or
code points. Specifically say that Char represents Unicode code points.

[skip ci]

Test Plan: Read it.

Reviewers: hvr, austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4051

21 months agoDocument a law for TH's Lift class
Ryan Scott [Sat, 30 Sep 2017 03:32:41 +0000 (23:32 -0400)] 
Document a law for TH's Lift class

Inspired by the discussion in #14296, I've decided to
document a law which is usually in the back of my mind when I'm using
Template Haskell's `Lift` class, but isn't formally stated anywhere.
That is, every `Lift` instance should satisfy (for all `x`):

```lang=haskell
$(lift x) == x
```

Test Plan: Read it

Reviewers: austin, goldfire, bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4050

21 months agouser-guide: Document -Weverything
Ben Gamari [Sat, 30 Sep 2017 03:29:47 +0000 (23:29 -0400)] 
user-guide: Document -Weverything

[skip ci]

Reviewers: hvr, austin, dfeuer

Reviewed By: dfeuer

Subscribers: rwbarton, thomie

GHC Trac Issues: #14284

Differential Revision: https://phabricator.haskell.org/D4043

21 months agoFix Raspberry Pi target name
Moritz Angermann [Thu, 28 Sep 2017 03:04:32 +0000 (11:04 +0800)] 
Fix Raspberry Pi target name

Summary:
For some reson, the `*`, that was supposed to be in D4031
got lost in the diff.

Reviewers: bgamari, austin, hvr, dfeuer

Reviewed By: dfeuer

Subscribers: rwbarton, thomie, erikd

Differential Revision: https://phabricator.haskell.org/D4044

21 months agoFix #13391 by checking for kind-GADTs
Richard Eisenberg [Tue, 15 Aug 2017 21:22:50 +0000 (17:22 -0400)] 
Fix #13391 by checking for kind-GADTs

The check is a bit gnarly, but I couldn't think of a better way.
See the new code in TcTyClsDecls.

test case: polykinds/T13391

21 months agomkDataConRep: fix bug in strictness signature (#14290)
Simon Marlow [Thu, 28 Sep 2017 17:08:45 +0000 (13:08 -0400)] 
mkDataConRep: fix bug in strictness signature (#14290)

The strictness signature for a data con wrapper wasn't including any
dictionary arguments, which meant that bangs on the fields of a
constructor with an existential context would be moved to the wrong
fields.  See T14290 for an example.

Test Plan:
* New test T14290
* validate

Reviewers: simonpj, niteria, austin, bgamari, erikd

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14290

Differential Revision: https://phabricator.haskell.org/D4040

21 months agoconfigure: Make sure we try all possible linkers
Ben Gamari [Wed, 27 Sep 2017 19:30:18 +0000 (15:30 -0400)] 
configure: Make sure we try all possible linkers

Previously if we had both ld.lld and ld.gold installed but a gcc which
didn't support -fuse-ld=lld we would fail when trying ld.lld and fall
immediately back to plain ld. Now we will try ld.gold as well. This was
brought to light by #14280, where using ld.bfd resulted in a broken
stage2 compiler.

Test Plan: Configure

Reviewers: angerman, hvr, austin

Reviewed By: angerman

Subscribers: rwbarton, thomie, erikd

GHC Trac Issues: #14280

Differential Revision: https://phabricator.haskell.org/D4038

21 months agobase: fdReady(): Ensure and doc that return values are always -1/0/1
Niklas Hambüchen [Wed, 27 Sep 2017 19:29:06 +0000 (15:29 -0400)] 
base: fdReady(): Ensure and doc that return values are always -1/0/1

Reviewers: bgamari, austin, hvr, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4010

21 months agofdReady(): Fix some C -Wconversion warnings.
Niklas Hambüchen [Wed, 27 Sep 2017 19:26:37 +0000 (15:26 -0400)] 
fdReady(): Fix some C -Wconversion warnings.

Btw, -Wconversion is off by default and not included in -Wall, -Wextra
or -pedantic, so I used it temporarily with -optc-Wconversion.

Reviewers: bgamari, austin, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3965

21 months agoAdd TODO about getMonotonicNSec() wrapping that can no longer happen.
Niklas Hambüchen [Wed, 27 Sep 2017 19:24:11 +0000 (15:24 -0400)] 
Add TODO about getMonotonicNSec() wrapping that can no longer happen.

Knowing this is important for followup commits, where we will subtract
getProcessElapsedTime() values from each other, in a way that assumes
that there is no wrapping every 49 days.

Reviewers: bgamari, austin, erikd, simonmar, NicolasT

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #14233

Differential Revision: https://phabricator.haskell.org/D3964

21 months agoMove check-ppr and check-api-annotations to testsuite/utils
Ben Gamari [Wed, 27 Sep 2017 19:22:37 +0000 (15:22 -0400)] 
Move check-ppr and check-api-annotations to testsuite/utils

These are needed by the testsuite and consequently must be shipped in
the testsuite tarball to ensure that we can test binary distributions.

See #13897.

Test Plan: Validate

Reviewers: austin

Subscribers: snowleopard, rwbarton, thomie

GHC Trac Issues: #13897

Differential Revision: https://phabricator.haskell.org/D4039

21 months agoTypofixes
Gabor Greif [Wed, 27 Sep 2017 10:21:33 +0000 (12:21 +0200)] 
Typofixes

21 months agollvm-targets: drop soft-float
Moritz Angermann [Mon, 25 Sep 2017 06:17:11 +0000 (14:17 +0800)] 
llvm-targets: drop soft-float

Summary:
The llvm-targets file records `mattr` values, and
while interrogating `clang` for the target, we might
stumble upon `+soft-float-abi`, however ghc does not support
full soft-float, and as such passing `+soft-float` to `llc`
will result in segfaults for any function passing float
registers F1, ... in the ARM Instruction Selection Pass.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4030

21 months agoGHC_LLVM_TARGET: Keep android OS
Moritz Angermann [Wed, 27 Sep 2017 01:20:31 +0000 (09:20 +0800)] 
GHC_LLVM_TARGET: Keep android OS

Summary:
Our usual GHC_CONVERT_OS macro, will turn any andoird* into android.
This however drops the essential androideabi part. As such for the
GHC_LLVM_TARGET we only convert the VENDOR, not the OS.

Reviewers: bgamari, austin, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

Differential Revision: https://phabricator.haskell.org/D4031

21 months agoSwitch VEH to VCH and allow disabling of SEH completely.
Tamar Christina [Tue, 26 Sep 2017 18:34:58 +0000 (14:34 -0400)] 
Switch VEH to VCH and allow disabling of SEH completely.

Exception handling on Windows is unfortunately a bit complicated.
But essentially the VEH Handlers we currently have are running too
early.

This was a problem as it ran so early it also swallowed C++ exceptions
and other software exceptions which the system could have very well
recovered from.

So instead we use a sequence of chains to for the exception handlers to
run as late as possible. You really can't get any later than this.

Please read the comment in the patch for more details.

I'm also providing a switch to allow people to turn off the exception
handling entirely. In case it does present a problem with their code.

(Reverted and recommitted to fix authorship information)

Test Plan: ./validate

Reviewers: austin, hvr, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13911, #12110

Differential Revision: https://phabricator.haskell.org/D3911

21 months agoRevert "Switch VEH to VCH and allow disabling of SEH completely."
Ben Gamari [Tue, 26 Sep 2017 19:43:47 +0000 (15:43 -0400)] 
Revert "Switch VEH to VCH and allow disabling of SEH completely."

Reverting to fix authorship of commit.

This reverts commit 1825cbdbdf08ed4bd6fd6794852596078953298a.

21 months agorts: Throw proper HeapOverflow exception on allocating large array
Ben Gamari [Tue, 26 Sep 2017 19:09:13 +0000 (15:09 -0400)] 
rts: Throw proper HeapOverflow exception on allocating large array

Test Plan: Validate, add tests

Reviewers: simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4021

21 months agodesugar: Catch levity polymorphism in unboxed sum expressions
Ben Gamari [Tue, 26 Sep 2017 18:52:26 +0000 (14:52 -0400)] 
desugar: Catch levity polymorphism in unboxed sum expressions

Fixes #13929.

21 months agobase: fdReady(): Add note about O_NONBLOCK requirement
Niklas Hambüchen [Tue, 26 Sep 2017 18:41:50 +0000 (14:41 -0400)] 
base: fdReady(): Add note about O_NONBLOCK requirement

Reviewers: bgamari, austin, hvr

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3962

21 months agoSwitch VEH to VCH and allow disabling of SEH completely.
Ben Gamari [Tue, 26 Sep 2017 18:34:58 +0000 (14:34 -0400)] 
Switch VEH to VCH and allow disabling of SEH completely.

Exception handling on Windows is unfortunately a bit complicated.
But essentially the VEH Handlers we currently have are running too
early.

This was a problem as it ran so early it also swallowed C++ exceptions
and other software exceptions which the system could have very well
recovered from.

So instead we use a sequence of chains to for the exception handlers to
run as late as possible. You really can't get any later than this.

Please read the comment in the patch for more details.

I'm also providing a switch to allow people to turn off the exception
handling entirely. In case it does present a problem with their code.

Test Plan: ./validate

Reviewers: austin, hvr, bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13911, #12110

Differential Revision: https://phabricator.haskell.org/D3911

21 months agorts: Silence missing __noreturn__ warning
Ben Gamari [Tue, 26 Sep 2017 18:34:58 +0000 (14:34 -0400)] 
rts: Silence missing __noreturn__ warning

Reviewers: angerman, austin, erikd, simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4034

21 months agoRules: Show the binder type in the unbound template binder error
Ben Gamari [Tue, 26 Sep 2017 18:32:02 +0000 (14:32 -0400)] 
Rules: Show the binder type in the unbound template binder error

Reviewers: austin

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4013

21 months agoRelease console for ghci wrapper
Tamar Christina [Tue, 26 Sep 2017 18:43:15 +0000 (19:43 +0100)] 
Release console for ghci wrapper

Summary:
It seems the call that caused issues with the gcc wrapper before
was needed for the ghci wrapper in order for the child process
to be the one handling console events.

This code slightly refactors the wrappers to make sure only ghci
calls FreeConsole and nothing else.

Test Plan: ./validate , open ghci.exe press ctrl+c

Reviewers: RyanGlScott, austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, erikd

GHC Trac Issues: #14150

Differential Revision: https://phabricator.haskell.org/D4028

21 months agoTcInteract: Remove redundant import of Typeable
Ben Gamari [Tue, 26 Sep 2017 17:35:46 +0000 (13:35 -0400)] 
TcInteract: Remove redundant import of Typeable

21 months agotestsuite: Add test for #14272
Ben Gamari [Tue, 26 Sep 2017 16:02:27 +0000 (12:02 -0400)] 
testsuite: Add test for #14272

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #14272

Differential Revision: https://phabricator.haskell.org/D4027

21 months agoPrelRules: Handle Int left shifts of more than word-size bits
Ben Gamari [Tue, 26 Sep 2017 12:01:44 +0000 (08:01 -0400)] 
PrelRules: Handle Int left shifts of more than word-size bits

This should result in zero. Failing to realize this caused us to try
to constant-fold via the normal path, resulting in #14272.

Test Plan: Validate with coming tests

Reviewers: austin, simonpj

Subscribers: simonpj, rwbarton, thomie, hvr

GHC Trac Issues: #14272

Differential Revision: https://phabricator.haskell.org/D4025

21 months agorts: Inform kernel that we won't need reserved address space
Ben Gamari [Tue, 26 Sep 2017 14:09:06 +0000 (10:09 -0400)] 
rts: Inform kernel that we won't need reserved address space

Trac #14192 points out that currently GHC's two-step allocator results
in extremely large coredumps. It seems like WebKit may have encountered
similar issues and their apparent solution uses madvise(MADV_DONTNEED)
while reserving address space to inform the kernel that the address
space we just requested needs no backing. Perhaps this is used by the
core dump logic to trim out uncommitted pages.

Test Plan: Validate, try core-dumping a compiled executable

Reviewers: austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #14192, #14193

Differential Revision: https://phabricator.haskell.org/D3929

21 months agoprimops: Add some notes regarding the meaning of the "type" field
Ben Gamari [Tue, 26 Sep 2017 13:33:53 +0000 (09:33 -0400)] 
primops: Add some notes regarding the meaning of the "type" field

The overloading of "monadic" definitely deserved some explanation.

[skip ci]

21 months agoStgCmmMonad: Remove unnecessary use of unboxed tuples
Ben Gamari [Tue, 26 Sep 2017 12:33:34 +0000 (08:33 -0400)] 
StgCmmMonad: Remove unnecessary use of unboxed tuples

The simplifier can simplify this without any trouble. Moreover, the
unboxed tuples cause bootstrapping issues due #14123.

I also went ahead and inlined a few definitions into the Monad instance.

Test Plan: Validate

Reviewers: austin, simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4026

21 months agoOmit Typeable from the "naturally coherent" list
Simon Peyton Jones [Tue, 26 Sep 2017 14:02:09 +0000 (15:02 +0100)] 
Omit Typeable from the "naturally coherent" list

In doing something else (Trac #14218) I tripped over the
definition of "naturally coherent" classes.  This patch

- Cocuments properly what that means

- Removes Typeable from the list, because now we know what
  it meams, Typeable clearly doesn't belong.

No regressions.

(Actually the term "naturally coherent" seems a bit off.
More like "invertible" or something.  But I left it.)

21 months agoA bunch of typofixes
Gabor Greif [Mon, 25 Sep 2017 10:31:12 +0000 (12:31 +0200)] 
A bunch of typofixes