15 months agoBump haddock submodule again ghc-8.4.2-rc1
Ben Gamari [Thu, 29 Mar 2018 17:59:00 +0000 (13:59 -0400)] 
Bump haddock submodule again

15 months agoDon't permit data types with return kind Constraint
Ryan Scott [Mon, 19 Mar 2018 16:06:41 +0000 (12:06 -0400)] 
Don't permit data types with return kind Constraint

Previously, GHC allowed all of the following:

data Foo1 :: Constraint
data family Foo2 :: Constraint
data family Foo3 :: k
data instance Foo3 :: Constraint

Yikes! This is because GHC was confusing `Type` with `Constraint`
due to careless use of the `isLiftedTypeKind` function. To respect
this distinction, I swapped `isLiftedTypeKind` out for
`tcIsStarKind`—which does respect this distinction—in the right

Test Plan: make test TEST="T14048a T14048b T14048c"

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: goldfire, rwbarton, thomie, carter

GHC Trac Issues: #14048

Differential Revision:

(cherry picked from commit f748c52997f61a9f58eccbf4b8df0a0c8c6887e5)

15 months agoFix tcDataKindSig
Simon Peyton Jones [Fri, 15 Dec 2017 09:29:12 +0000 (09:29 +0000)] 
Fix tcDataKindSig

This patch fixes an outright bug in tcDataKindSig, shown up in Trac
of a data type declaration.  See Note [TyConBinders for the result kind
signature of a data type]

I also took the opportunity to elminate the DataKindCheck argument
and data type from tcDataKindSig, instead moving the check to the
call site, which is easier to understand.

(cherry picked from commit 68149452a793aedd8d468b689dc93fb2ba5ec436)

15 months agoRevert "GHCi: Don't remove shadowed bindings from typechecker scope."
Ömer Sinan Ağacan [Thu, 8 Mar 2018 18:42:22 +0000 (21:42 +0300)] 
Revert "GHCi: Don't remove shadowed bindings from typechecker scope."

This reverts commit 59d7ee53906b9cee7f279c1f9567af7b930f8636 and enables
the test for #14052.

(See #14052 for the discussion)

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14052

Differential Revision:

(cherry picked from commit 98c7749cd360293bee96034056e260d70224cef6)

15 months agoFix typo in user guide about ConstraintKinds
Frank Steffahn [Tue, 13 Mar 2018 22:29:04 +0000 (23:29 +0100)] 
Fix typo in user guide about ConstraintKinds

The backslash currently in this type signature makes no sense. Without it, the example is fine.

(cherry picked from commit 960cd424fb2ca99389c8f041d519d661494d07c1)

15 months agoBump Cabal submodule to
Ben Gamari [Wed, 28 Mar 2018 17:13:36 +0000 (13:13 -0400)] 
Bump Cabal submodule to

15 months agoBump Haddock submodule
Ben Gamari [Mon, 26 Mar 2018 21:07:01 +0000 (17:07 -0400)] 
Bump Haddock submodule

15 months agoBump xhtml submodule to 3000.2.2.1
Ben Gamari [Mon, 26 Mar 2018 21:06:18 +0000 (17:06 -0400)] 
Bump xhtml submodule to 3000.2.2.1

15 months agoFix a nasty bug in the pure unifier
Simon Peyton Jones [Mon, 26 Feb 2018 17:44:55 +0000 (17:44 +0000)] 
Fix a nasty bug in the pure unifier

The pure unifier was building an infinite type, through a defective
occurs check.  So GHC went into an infinite loop.

Reason: we were neglecting the 'kco' part of the type, which
'unify_ty' maintains.  Yikes.

The fix is easy.  I refactored a bit to make it harder to
go wrong in future.

(cherry picked from commit e99fdf775540440c1c58dc5ade3c5984dc49246f)

15 months agoFix two pernicious bugs in DeriveAnyClass
Ryan Scott [Sun, 25 Mar 2018 18:00:39 +0000 (14:00 -0400)] 
Fix two pernicious bugs in DeriveAnyClass

The way GHC was handling `DeriveAnyClass` was subtly wrong
in two notable ways:

* In `inferConstraintsDAC`, we were //always// bumping the `TcLevel`
  of newly created unification variables, under the assumption that
  we would always place those unification variables inside an
  implication constraint. But #14932 showed precisely the scenario
  where we had `DeriveAnyClass` //without// any of the generated
  constraints being used inside an implication, which made GHC
  incorrectly believe the unification variables were untouchable.
* Even worse, we were using the generated unification variables from
  `inferConstraintsDAC` in every single iteration of `simplifyDeriv`.
  In #14933, however, we have a scenario where we fill in a
  unification variable with a skolem in one iteration, discard it,
  proceed on to another iteration, use the same unification variable
  (still filled in with the old skolem), and try to unify it with
  a //new// skolem! This results in an utter disaster.

The root of both these problems is `inferConstraintsDAC`. This patch
fixes the issue by no longer generating unification variables
directly in `inferConstraintsDAC`. Instead, we store the original
variables from a generic default type signature in `to_metas`, a new
field of `ThetaOrigin`, and in each iteration of `simplifyDeriv`, we
generate fresh meta tyvars (avoiding the second issue). Moreover,
this allows us to more carefully fine-tune the `TcLevel` under which
we create these meta tyvars, fixing the first issue.

Test Plan: make test TEST="T14932 T14933"

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14932, #14933

Differential Revision:

(cherry picked from commit 9893042604cda5260cb0f7b674ed5c34b419e403)

15 months agoUnboxedTuples can't be used as constraints
HE, Tao [Thu, 1 Feb 2018 02:40:03 +0000 (21:40 -0500)] 
UnboxedTuples can't be used as constraints

Fixes #14740.

Test Plan: make test TEST="14740"

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #14740

Differential Revision:

(cherry picked from commit ced9fbd3913e1316498961bc389bfb1e141221a1)

15 months agoFix #14934 by including axSub0R in typeNatCoAxiomRules
Ryan Scott [Mon, 19 Mar 2018 16:05:36 +0000 (12:05 -0400)] 
Fix #14934 by including axSub0R in typeNatCoAxiomRules

For some reason, `axSub0R` was left out of `typeNatCoAxiomRules` in
`TcTypeNats`, which led to disaster when trying to look up `Sub0R` from
an interface file, as demonstrated in #14934.

The fix is simple—just add `axSub0R` to that list. To help prevent
an issue like this happening in the future, I added a
`Note [Adding built-in type families]` to `TcTypeNats`, which
contains a walkthrough of all the definitions in `TcTypeNats` you
need to update when adding a new built-in type family.

Test Plan: make test TEST=T14934

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #14934

Differential Revision:

(cherry picked from commit c3aea39678398fdf88166f30f0d01225a1874a32)

15 months agoFix seq# case of exprOkForSpeculation
Simon Peyton Jones [Tue, 20 Mar 2018 16:30:01 +0000 (16:30 +0000)] 
Fix seq# case of exprOkForSpeculation

This subtle patch fixes Trac #5129 (again; comment:20
and following).

I took the opportunity to document seq# properly; see
Note [seq# magic] in PrelRules, and Note [seq# and expr_ok]
in CoreUtils.

(cherry picked from commit abaf43d9d88d6fdf7345b936a571d17cfe1fa140)

15 months agoFix over-eager constant folding in bitInteger
Simon Peyton Jones [Thu, 22 Mar 2018 09:51:24 +0000 (09:51 +0000)] 
Fix over-eager constant folding in bitInteger

The RULE for bitInteger was trying to constant-fold

    bitInteger 9223372036854775807#

which meant constructing a gigantic Integer at compile
time.  Very bad idea!  Easily fixed.

Fixes Trac #14959, #14962.

(cherry picked from commit efc844f5b955385d69d8e20b80d38311083a6665)

15 months agoFix a debug print in disassembler (#14905)
Ömer Sinan Ağacan [Fri, 9 Mar 2018 12:38:58 +0000 (15:38 +0300)] 
Fix a debug print in disassembler (#14905)

When interpreter is not profiled (see `interpreterProfiled` in
`DynFlags`) bytecode generator generates a NULL pointer as the cost
centre of a `BRK_FUN` instruction:

    let cc | interpreterProfiled dflags = cc_arr ! tick_no
           | otherwise = toRemotePtr nullPtr
    let breakInstr = BRK_FUN (fromIntegral tick_no) (getUnique this_mod) cc
    return $ breakInstr `consOL` code

We now take this into account when disassembling `BRK_FUN`.

Reviewers: bgamari, simonmar, erikd

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit 8e3410134bd7419db638988d74fcc600b03e2a1a)

15 months agoSlighly improve infix con app pattern errors
Ömer Sinan Ağacan [Wed, 14 Mar 2018 06:16:51 +0000 (09:16 +0300)] 
Slighly improve infix con app pattern errors

Given this program:

    main = do
      f $ do
        a <- return 3
          c <- do
          return 5

GHC previously gave this error message:

    Main.hs:2:7: error:
        Parse error in pattern: do a <- return 3 c
        Possibly caused by a missing 'do'?
    2 |   f $ do
      |       ^^...

What happened is GHC considered the whole `f $ do a <- return 3 c` as a
pattern. When parsed as an expression it becomes an infix application of
`($)`, and GHC checks left and right hand sides before checking if `($)`
is a valid infix constructor name, and shows the first error it got.

If instead we first check if the infix op is valid in pattern context,
the error message becomes much clearer:

    Main.hs:2:3: error:
        Parse error in pattern: f $ do a <- return 3 c
        Possibly caused by a missing 'do'?
    2 |   f $ do
      |   ^^^^^^...

This may not entirely fix #11188 but I think it's an improvement.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #11188

Differential Revision:

(cherry picked from commit cb6d8589c83247ec96d5faa82df3e93f419bbfe0)

15 months agobase: Fix Unicode handling of TyCon's Show instance
Ben Gamari [Mon, 26 Mar 2018 02:12:49 +0000 (22:12 -0400)] 
base: Fix Unicode handling of TyCon's Show instance

Test Plan: `make test TEST=T14925`

Reviewers: hvr, dfeuer

Reviewed By: dfeuer

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14925

Differential Revision:

(cherry picked from commit 20ae19fc7297dceaefde8d3443099bfd9cd1e905)

15 months agoFix #14916 with an additional validity check in deriveTyData
Ryan Scott [Sun, 25 Mar 2018 19:34:05 +0000 (15:34 -0400)] 
Fix #14916 with an additional validity check in deriveTyData

Manually-written instances and standalone-derived instances
have the benefit of having the `checkValidInstHead` function run over
them, which catches manual instances of built-in types like `(~)` and
`Coercible`. However, instances generated from `deriving` clauses
weren't being passed through `checkValidInstHead`, leading to
confusing results as in #14916.

`checkValidInstHead` also has additional validity checks for language
extensions like `FlexibleInstances` and `MultiParamTypeClasses`. Up
until now, GHC has never required these language extensions for
`deriving` clause, so to avoid unnecessary breakage, I opted to
suppress these language extension checks for `deriving` clauses, just
like we currently suppress them for `SPECIALIZE instance` pragmas.

Test Plan: make test TEST=T14916

Reviewers: goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14916

Differential Revision:

(cherry picked from commit 20f14b4fd4eaf2c3ab375b8fc6d40ee9e6db94fd)

15 months agoDon't refer to blocks in debug info when -g1
Bartosz Nitka [Sun, 25 Mar 2018 19:34:27 +0000 (15:34 -0400)] 
Don't refer to blocks in debug info when -g1

-g1 removes block information, but it turns out that procs can
refer to block information through parents.
Note [Splitting DebugBlocks] explains the parentage relationship.

Test Plan:
* ./validate
* added a new test

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14894

Differential Revision:

(cherry picked from commit 0cbb13b3dfd70b4c9665109cd6c4a150cb7b99df)

15 months agorelnotes: Fix parsing of Version: field from Cabal file
Ben Gamari [Mon, 19 Mar 2018 17:31:46 +0000 (13:31 -0400)] 
relnotes: Fix parsing of Version: field from Cabal file

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit d718023e86c8681b87f212bd64eb6ca10ac8935e)

15 months agoSpecial-case record fields ending with hash when deriving Read
Ryan Scott [Fri, 23 Mar 2018 15:40:02 +0000 (11:40 -0400)] 
Special-case record fields ending with hash when deriving Read

In commit dbd81f7e86514498218572b9d978373b1699cc5b, a
regression was inadvertently introduced which caused derived `Read`
instances for record data types with fields ending in a `#` symbol
(using `MagicHash`) would no longer parse on valid output. This
is ultimately due to the same reasons as #5041, as we cannot parse
a field name like `foo#` as a single identifier. We fix this issue
by employing the same workaround as in #5041: first parse the
identifier name `foo`, then then symbol `#`.

This is accomplished by the new `readFieldHash` function in
`GHC.Read`. This will likely warrant a `base-` release.

Test Plan: make test TEST=T14918

Reviewers: tdammers, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14918

Differential Revision:

(cherry picked from commit d5577f44eaf3b9dfdfc77828038782bf818c176a)

15 months agoconfigure: Accept suffix in OpenBSD triple's OS name
Ben Gamari [Thu, 8 Mar 2018 18:29:01 +0000 (13:29 -0500)] 
configure: Accept suffix in OpenBSD triple's OS name

Reviewers: hvr

Subscribers: rwbarton, thomie, erikd, carter

Differential Revision:

(cherry picked from commit a25b763fa9e09d3bf7c82fef1eaed89a7afc54f7)

15 months agoconfigure: Accept version suffix in solaris name
Ben Gamari [Mon, 19 Mar 2018 17:32:14 +0000 (13:32 -0400)] 
configure: Accept version suffix in solaris name

Summary: OpenIndiana apparently reports a triple of i386-pc-solaris2.11.

Reviewers: hvr

Subscribers: rwbarton, thomie, erikd, carter

Differential Revision:

(cherry picked from commit 4fa077a2a1d6e6e7a45ef03a1075ff3c7dddb23d)

16 months agoconfigure: Accept version suffix in solaris name
Ben Gamari [Thu, 8 Mar 2018 20:26:09 +0000 (15:26 -0500)] 
configure: Accept version suffix in solaris name

OpenIndiana apparently reports a triple of i386-pc-solaris2.11.

16 months agoconfigure: Set RELEASE=NO
Ben Gamari [Thu, 8 Mar 2018 19:09:36 +0000 (14:09 -0500)] 
configure: Set RELEASE=NO

16 months agorel-notes: Fix typo
Ben Gamari [Thu, 8 Mar 2018 03:17:18 +0000 (22:17 -0500)] 
rel-notes: Fix typo

Thanks to Gabor for pointing this out.

16 months agoFix interpreter with profiling
Simon Marlow [Mon, 5 Mar 2018 20:12:57 +0000 (15:12 -0500)] 
Fix interpreter with profiling

This was broken by D3746 and/or D3809, but unfortunately we didn't
notice because CI at the time wasn't building the profiling way.

Test Plan:
cd testsuite/test/profiling/should_run
make WAY=ghci-ext-prof

Reviewers: bgamari, michalt, hvr, erikd

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14705

Differential Revision:

(cherry picked from commit 488d63d6899d223ef87c26c218f0cf81ac670a90)

16 months agoforkProcess: fix task mutex release order
Ömer Sinan Ağacan [Fri, 2 Mar 2018 16:15:03 +0000 (11:15 -0500)] 
forkProcess: fix task mutex release order

`all_tasks_mutex` should be released before calling `releaseCapability_`
in the parent process as `releaseCapability_` spawns worker tasks in
some cases.

Reviewers: bgamari, erikd, simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14538

Differential Revision:

(cherry picked from commit e261b8523eb547b93b8b9e194bc2566350e7cc60)

16 months agoSet RELEASE=YES, version 8.4.1
Ben Gamari [Sun, 4 Mar 2018 18:53:54 +0000 (13:53 -0500)] 
Set RELEASE=YES, version 8.4.1

16 months agoBump hsc2hs submodule
Ben Gamari [Tue, 6 Mar 2018 16:48:41 +0000 (11:48 -0500)] 
Bump hsc2hs submodule

16 months agoadd CCX=$(CXX) to integer-gmp
Moritz Angermann [Tue, 6 Mar 2018 03:20:22 +0000 (11:20 +0800)] 
add CCX=$(CXX) to integer-gmp

This came up when trying to build GHC HEAD with nix. We
do not set CCX for integer-gmp when running ./configure. We do
this however for libffi.

The result is, that if CCX is not set, we default to the system
one, of which there might be none (as in nixos's case).  This
will not show on a debian+nix or similar setup, where the system
`cxx` is still in place, and only shows up when the system tries
hard to sandbox everything (even cxx) as nixOS does.

We use `CXX`, which is set to either `clang` or `CC_STAGE1`, and
also usedfor `CC`, similar to what we do for libffi.c

Test Plan: ./validate

Reviewers: bgamari, hvr

Reviewed By: hvr

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit cf5bc96e1b023275ec3c0399f3345ceebbc48df0)

16 months agoAllow top level ticked string literals
Bartosz Nitka [Fri, 2 Mar 2018 13:33:07 +0000 (05:33 -0800)] 
Allow top level ticked string literals

This reverts f5b275a239d2554c4da0b7621211642bf3b10650
and changes the places that looked for `Lit (MachStr _))`
to use `exprIsMbTickedLitString_maybe` to unwrap ticks as
Also updated relevant comments.

Test Plan:
I added 3 new tests that previously reproduced.
GHC HEAD now builds with -g

Reviewers: simonpj, simonmar, bgamari, hvr, goldfire

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14779

Differential Revision:

(cherry picked from commit 5bc195a2caddc5c29cf24e9c731dd8d5050f2c66)

16 months agoAnother Cabal submodule bump
Ben Gamari [Tue, 6 Mar 2018 16:11:51 +0000 (11:11 -0500)] 
Another Cabal submodule bump

16 months agoFixup include of gmp/ to use new location
Herbert Valerio Riedel [Mon, 5 Mar 2018 20:13:28 +0000 (21:13 +0100)] 
Fixup include of gmp/ to use new location

This wasn't spotted rightaway in
because the include-site deliberately ignored include-errors as
a Hack with the justification below:

> Hack. The file gmp/ doesn't exist yet after running ./configure in
> the toplevel (ghc) directory. To let some toplevel make commands such as
> sdist go through, right after ./configure, don't consider this an error.

This may have contributed to #14891.

(cherry picked from commit df7ac37d43bdbabbde9b09344f9425e8e5a879ff)

16 months agoCorrect -g flag description
Bartosz Nitka [Mon, 5 Mar 2018 20:14:36 +0000 (15:14 -0500)] 
Correct -g flag description

Since 7aaeaf81ea95c36fe1dc4da449cf6092a792fd09
`-g1` and `-g2` are actually different.
The tutorial below is correct.

Test Plan: harbormaster

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit 5b1132eefd0a75189b3527486b492c3dffc7bdf1)

16 months agoOne final sweep over release notes
Ben Gamari [Sun, 4 Mar 2018 17:42:05 +0000 (12:42 -0500)] 
One final sweep over release notes

16 months agoBump Cabal submodule to 2.2
Moritz Angermann [Sat, 3 Mar 2018 21:16:41 +0000 (16:16 -0500)] 
Bump Cabal submodule to 2.2

Requires some ghc-cabal changes as well.

Test Plan: ./validate

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: hsyl20, erikd, alpmestan, rwbarton, thomie, carter

Differential Revision:

16 months agoVarious documentation improvements
Sergey Vinokurov [Wed, 7 Feb 2018 21:10:17 +0000 (21:10 +0000)] 
Various documentation improvements

 * Fix missing code example in changelog for 8.4.1

 * List 'setEnv' as opposite of 'getEnv'

   It seems best to direct users to use 'System.Environment.setEnv'
   rather than 'System.Posix.Env.putEnv'. This is due to 'setEnv' being
   located in the same module as 'getEnv' and my virtue of working on
   Windows platform, whereas 'putEnv' does not have that quality because
   it's part of the 'unix' package.

 * Reflect in docs the fact that 'readMVar' is not a composition of
   'takeMVVar' and 'putMVar' any more

(cherry picked from commit df449e1744d59eef7f41e09196629bc01815e984)

16 months agoconfigure: Enable LD_NO_GOLD is set in all codepaths
Ben Gamari [Fri, 2 Mar 2018 21:13:53 +0000 (16:13 -0500)] 
configure: Enable LD_NO_GOLD is set in all codepaths

Test Plan: `./configure --disable-ld-override; make; make install`

Reviewers: trofi, hvr

Reviewed By: trofi

Subscribers: rwbarton, thomie, erikd, carter, simonmar

GHC Trac Issues: #14675

Differential Revision:

(cherry picked from commit bc1bcaa2c0c66fb247d1338d6d0055a833918a7f)

16 months agoAdds *-cross-ncg flavour.
Moritz Angermann [Fri, 2 Mar 2018 21:15:09 +0000 (16:15 -0500)] 
Adds *-cross-ncg flavour.

Our *-cross flavours force -fllvm, this adds flavours for cross
compilation to x86_64, where we can use our native code generator.

Test Plan: ./validate

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit e4dcebf899c796a13dabf8964038f78505b9f4ec)

16 months agoCorrect default -A value in RTS flag usage info
Simon Jakobi [Fri, 2 Mar 2018 21:17:44 +0000 (16:17 -0500)] 
Correct default -A value in RTS flag usage info

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit 821daadf65a3e146f8adf2802b3cb8b520d8d10e)

16 months agoUpdate haddock submodule
Ben Gamari [Sun, 25 Feb 2018 22:12:44 +0000 (17:12 -0500)] 
Update haddock submodule

Fixes file handle leak

16 months agoFix typo
Sergey Vinokurov [Thu, 8 Feb 2018 09:17:53 +0000 (09:17 +0000)] 
Fix typo

(cherry picked from commit 37e78029845a04d0ab4cc05e1790c648facdcb1f)

16 months agoList 'setEnv' as opposite of 'getEnv'
Sergey Vinokurov [Wed, 7 Feb 2018 21:49:56 +0000 (21:49 +0000)] 
List 'setEnv' as opposite of 'getEnv'

It seems best to direct users to use 'System.Environment.setEnv'
rather than 'System.Posix.Env.putEnv'. This is due to 'setEnv' being
located in the same module as 'getEnv' and my virtue of working on
Windows platform, whereas 'putEnv' does not have that quality because
it's part of the 'unix' package.

(cherry picked from commit c74fcf5d27744c67b09b29a78029c31c9371cf41)

16 months agoFix missing code example in changelog for 8.4.1
Sergey Vinokurov [Wed, 7 Feb 2018 21:10:17 +0000 (21:10 +0000)] 
Fix missing code example in changelog for 8.4.1

(cherry picked from commit 3ae408cf93d10b9a2e5acb4186dc8e0c62e0afb6)

16 months agoBump unix submodule back to 2.7 ghc-8.4.1-rc1
Ben Gamari [Fri, 23 Feb 2018 21:57:33 +0000 (16:57 -0500)] 
Bump unix submodule back to 2.7

16 months agoDon't use when building libraries for GHCi
Simon Marlow [Wed, 21 Feb 2018 14:16:00 +0000 (14:16 +0000)] 
Don't use when building libraries for GHCi

Summary: is buggy when using -r and a linker script.  See upstream bug

This has been causing various brokenness for the GHC runtime linker,
where we load these broken object files.

Test Plan: Test program from #14675

Reviewers: bgamari, RyanGlScott, alpmestan, hvr, erikd

Subscribers: rwbarton, thomie, erikd, carter

GHC Trac Issues: #14328, #14675, #14291

Differential Revision:

(cherry picked from commit 0a3629af36e89de73b7012c726fd533c4c5460fb)

16 months agoImprove unboxed sum documentation
David Feuer [Mon, 5 Feb 2018 14:45:30 +0000 (09:45 -0500)] 
Improve unboxed sum documentation

* Clarify the representation of sums without fields.
* Try to improve language, clarity, and examples.

Fixes #14752

Reviewers: osa1, bgamari

Reviewed By: osa1

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14752

Differential Revision:

(cherry picked from commit d987f71aa3200ce0c94bc57c43b4fcc92eaccf76)

16 months agoBump hadrian submodule
Ryan Scott [Fri, 16 Feb 2018 18:51:27 +0000 (13:51 -0500)] 
Bump hadrian submodule

16 months agoBump haddock submodule
Ben Gamari [Mon, 19 Feb 2018 05:00:06 +0000 (00:00 -0500)] 
Bump haddock submodule

16 months agoCBE: re-introduce bgamari's fixes
Michal Terepeta [Sun, 18 Feb 2018 16:09:40 +0000 (11:09 -0500)] 
CBE: re-introduce bgamari's fixes

During some recent work on CBE we discovered that `zipWith` is used to
check for equality, but that doesn't quite work if lists are of
different lengths! This was fixed by bgamari, but unfortunately the fix
had to be rolled back due to other changes in CBE in
50adbd7c5fe5894d3e6e2a58b353ed07e5f8949d. Since I wanted to have another
look at CBE anyway, we agreed that the first thing to do would be to
re-introduce the fix.

Sadly I don't have any actual test case that would exercise this.

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

Reviewers: bgamari, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14226

Differential Revision:

(cherry picked from commit 4e513bf758c32804fc71b98215f96e8481697a36)

16 months agoImplement stopgap solution for #14728
Ryan Scott [Sun, 18 Feb 2018 16:00:40 +0000 (11:00 -0500)] 
Implement stopgap solution for #14728

It turns out that one can produce ill-formed Core by
combining `GeneralizedNewtypeDeriving`, `TypeInType`, and
`TypeFamilies`, as demonstrated in #14728. The root of the problem
is allowing the last parameter of a class to appear in a //kind// of
an associated type family, as our current approach to deriving
associated type family instances simply doesn't work well for that

Although it might be possible to properly implement this feature
today (see
for a sketch of how this might work), there does not currently exist
a performant implementation of the algorithm needed to accomplish
this. Until such an implementation surfaces, we will make this corner
case of `GeneralizedNewtypeDeriving` an error.

Test Plan: make test TEST="T14728a T14728b"

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14728

Differential Revision:

(cherry picked from commit 1ede46d415757f53af33bc6672bd9d3fba7f205d)

16 months agoBuild Haddocks with --quickjump
Ben Gamari [Sun, 18 Feb 2018 16:01:59 +0000 (11:01 -0500)] 
Build Haddocks with --quickjump

By request of @alexbiehl.
CCing @snowleopard and @alpmestan as the same should be done in Hadrian.

Bumps haddock submodule.

Reviewers: alexbiehl

Reviewed By: alexbiehl

Subscribers: rwbarton, thomie, carter, snowleopard, alpmestan, alexbiehl

Differential Revision:

(cherry picked from commit 9ff4cce373765cec064e2a41d4c6ddd84b873f04)

16 months agoBump text submodule to
Ben Gamari [Sun, 18 Feb 2018 16:31:41 +0000 (11:31 -0500)] 
Bump text submodule to

16 months agoBump haskeline submodule to
Ben Gamari [Sun, 18 Feb 2018 16:29:56 +0000 (11:29 -0500)] 
Bump haskeline submodule to

16 months agotestsuite: Add test for #14768
Ben Gamari [Tue, 6 Feb 2018 22:33:21 +0000 (17:33 -0500)] 
testsuite: Add test for #14768

(cherry picked from commit da4681303892804ea08b60bfd47cbb82ca8e6589)

16 months agoCollect CCs in CorePrep, including CCs in unfoldings
Ömer Sinan Ağacan [Tue, 13 Feb 2018 06:03:57 +0000 (09:03 +0300)] 
Collect CCs in CorePrep, including CCs in unfoldings

This patch includes two changes:

1. Move cost centre collection from `SCCfinal` to `CorePrep`, to be able
   to collect cost centres in unfoldings. `CorePrep` drops unfoldings, so
   that's the latest stage in the compilation pipeline for this.

   After this change `SCCfinal` no longer collects all cost centres, but
   it still generates & collects CAF cost centres + updates cost centre
   stacks of `StgRhsClosure` and `StgRhsCon`s.

   This fixes #5889.

2. Initialize cost centre stack fields of `StgRhs` in `coreToStg`. With
   this we no longer need to update cost centre stack fields in
   `SCCfinal`, so that module is removed.

   Cost centre initialization explained in Note [Cost-centre
   initialization plan].

   Because with -fcaf-all we need to attach a new cost-centre to each
   CAF, `coreTopBindToStg` now returns `CollectedCCs`.

Test Plan: validate

Reviewers: simonpj, bgamari, simonmar

Reviewed By: simonpj, bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #5889

Differential Revision:

(cherry picked from commit 5957405808fe89e9b108dc0bc3cf4b56aec37775)

16 months agoRemove unused extern cost centre collection
Ömer Sinan Ağacan [Thu, 18 Jan 2018 16:06:30 +0000 (11:06 -0500)] 
Remove unused extern cost centre collection

Reviewers: bgamari, simonmar

Reviewed By: simonmar

Subscribers: alexbiehl, rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit 2a78cf773cb447ac91c4a23d7e921e091e499134)

16 months agoFix #14811 by wiring in $tcUnit#
Ryan Scott [Fri, 16 Feb 2018 18:51:27 +0000 (13:51 -0500)] 
Fix #14811 by wiring in $tcUnit#

Previously, we were skipping over `$tcUnit#` entirely when
wiring in `Typeable` tycons, resulting in #14811. Easily fixed.

Test Plan: make test TEST=T14811

Reviewers: bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, rwbarton, thomie, carter

GHC Trac Issues: #14811

Differential Revision:

(cherry picked from commit d5ac5820111bc957e72c8ce11e59d7cbbdd63526)

16 months agobase: Fix changelog entry for openTempFile
Ben Gamari [Thu, 15 Feb 2018 18:01:09 +0000 (13:01 -0500)] 
base: Fix changelog entry for openTempFile

This change is present in

(cherry picked from commit abecb2619acea5cf6ebaa7412401d9e660daf82c)

16 months agoBump parsec submodule to
Ben Gamari [Thu, 15 Feb 2018 16:43:35 +0000 (11:43 -0500)] 
Bump parsec submodule to

17 months agoBump primitive submodule to
Ben Gamari [Thu, 15 Feb 2018 16:42:35 +0000 (11:42 -0500)] 
Bump primitive submodule to

17 months agoFix isDroppableCt (Trac #14763)
Simon Peyton Jones [Thu, 8 Feb 2018 14:24:11 +0000 (14:24 +0000)] 
Fix isDroppableCt (Trac #14763)

When finishing up an implication constraint, it's a bit tricky to
decide which Derived constraints to retain (for error reporting) and
which to discard.  I got this wrong in commit
   (Remove wc_insol from WantedConstraints)

The particular problem in Trac #14763 was that we were reporting as an
error a fundep-generated constraint
  (ex ~ T)
where 'ex' is an existentially-bound variable in a pattern match.
But this isn't really an error at all.

This patch fixes the problem. Indeed, since I had to understand
this rather tricky code, I took the opportunity to clean it up
and document better.  See
  isDroppableCt :: Ct -> Bool
and Note [Dropping derived constraints]

I also removed wl_deriv altogether from the WorkList data type.  It
was there in the hope of gaining efficiency by not even processing
lots of derived constraints, but it has turned out that most derived
constraints (notably equalities) must be processed anyway; see
Note [Prioritise equalities] in TcSMonad.

The two are coupled because to decide which constraints to put in
wl_deriv I was using another variant of isDroppableCt.  Now it's much
simpler -- and perhaps even more efficient too.

(cherry picked from commit 6edafe3be0133fe69581fb3851a812c69ab9dbf7)

17 months agoFix utterly bogus TagToEnum rule in caseRules
Simon Peyton Jones [Wed, 7 Feb 2018 09:55:14 +0000 (09:55 +0000)] 
Fix utterly bogus TagToEnum rule in caseRules

In prelRules we had:

  tx_con_tte :: DynFlags -> AltCon -> AltCon
  tx_con_tte _      DEFAULT      = DEFAULT
  tx_con_tte dflags (DataAlt dc)
    | tag == 0  = DEFAULT   -- See Note [caseRules for tagToEnum]
    | otherwise = LitAlt (mkMachInt dflags (toInteger tag))

The tag==0 case is totally wrong, and led directly to Trac #14768.

See "Beware" in Note [caseRules for tagToEnum] (in the patch).

Easily fixed, though!

(cherry picked from commit 4aa98f4a3cb0c965c4df19af2f1ccc2c5483c3a5)

17 months agoUse SPDX syntax in rts/
Herbert Valerio Riedel [Wed, 7 Feb 2018 17:36:13 +0000 (18:36 +0100)] 
Use SPDX syntax in rts/

This was an oversight from 2671cccde749ed64129097358f81bff43480cdb9
as it wasn't obvious to assume one would go the trouble to manually
construct the pkg-db entries... :-)

(cherry picked from commit be53d19e08c8b6db338c9027db5a0635f470f32f)

17 months agoBump transformers submodule to ghc-8.4.1-alpha3
Ben Gamari [Mon, 22 Jan 2018 01:09:20 +0000 (20:09 -0500)] 
Bump transformers submodule to

(cherry picked from commit 24e56ebd010846683b236b6ef3678c2217640120)

17 months agotestsuite: Add testcase for #14754
Ben Gamari [Sun, 4 Feb 2018 00:19:08 +0000 (19:19 -0500)] 
testsuite: Add testcase for #14754

(cherry picked from commit 606edbfba14b025ce85a02e5ed7c03e8a097d692)

17 months agocmm: Revert more aggressive CBE due to #14226
Ben Gamari [Sun, 4 Feb 2018 00:49:21 +0000 (19:49 -0500)] 
cmm: Revert more aggressive CBE due to #14226

Trac #14226 noted that the C-- CBE pass frequently fails to
common up semantically identical blocks due to the differences in local
register naming. These patches fixed this by making the pass consider
equality up to alpha-renaming.

However, the new logic failed to consider the possibility that local
register naming *may* matter across multiple blocks. This lead to the
regression #14754. I'll need to do a bit of thinking on a proper
solution to this but in the meantime I'm reverting all four patches.

This reverts commit a27056f9823f8bbe2302f1924b3ab38fd6752e37.
This reverts commit 6f990c54f922beae80362fe62426beededc21290.
This reverts commit 9aa73892e10e90a1799b9277da593e816a827364.
This reverts commit 7920a7d9c53083b234e060a3e72f00b601a46808.

(cherry picked from commit 50adbd7c5fe5894d3e6e2a58b353ed07e5f8949d)

17 months agoBump stm submodule to
Ben Gamari [Sat, 3 Feb 2018 21:23:05 +0000 (16:23 -0500)] 
Bump stm submodule to

17 months agointeger-gmp: Simplify gmp/configure invocation
Ben Gamari [Fri, 2 Feb 2018 18:58:14 +0000 (13:58 -0500)] 
integer-gmp: Simplify gmp/configure invocation

There weas lots of historical cruft to be found here. The `export
SHELLOPTS` breaks on NixOS due to bash syntax in the gcc wrapper script.

Reviewers: hvr

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit 3441b1455bf9f2e7cc9e064e3edae3607c70a1c0)

17 months agoDon't apply dataToTag's caseRules for data families
Ryan Scott [Sat, 3 Feb 2018 16:40:43 +0000 (11:40 -0500)] 
Don't apply dataToTag's caseRules for data families

Commit 193664d42dbceadaa1e4689dfa17ff1cf5a405a0 added a
special caseRule for `dataToTag`, but this transformation completely
broke when `dataToTag` was applied to somewith with a type headed by
a data family, leading to #14680. For now at least, the simplest
solution is to simply not apply this transformation when the type is
headed by a data family.

Test Plan: make test TEST=T14680

Reviewers: simonpj, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14680

Differential Revision:

(cherry picked from commit d8a0e6d322deaa3743c95a11a6b7272577d1f86e)

17 months agoghc-prim: Emulate C11 atomics when not available
Ben Gamari [Sat, 3 Feb 2018 16:37:01 +0000 (11:37 -0500)] 
ghc-prim: Emulate C11 atomics when not available

GCC's __sync primitives apparently "usually" imply a full barrier,
meaning they can be used to emulate the more precise C11 atomics albeit
with a loss of efficiency. This restores compatibility with GCC 4.4.

This partially reverts commit 59de290928e6903337f31c1f8107ac8a98ea145d.

Test Plan: Validate on Centos

Reviewers: hvr, simonmar, trommler

Subscribers: rwbarton, thomie, erikd, carter

GHC Trac Issues: #14244

Differential Revision:

(cherry picked from commit 217e4170bdce3df28a667803ce5e619553bfecdd)

17 months agoUpgrade containers submodule
David Feuer [Fri, 2 Feb 2018 18:58:28 +0000 (13:58 -0500)] 
Upgrade containers submodule

Reviewers: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit fdf518c708dc5a34ae810c5d5f3a4db812d226f0)

17 months agoOption for LINE pragmas to get lexed into tokens
Alec Theriault [Fri, 26 Jan 2018 18:09:58 +0000 (13:09 -0500)] 
Option for LINE pragmas to get lexed into tokens

This adds a parser-level switch to have 'LINE' and 'COLUMN'
pragmas lexed into actual tokens (as opposed to updating the
position information in the parser).

'lexTokenStream' is the only place where this option is enabled.

Reviewers: bgamari, alexbiehl, mpickering

Reviewed By: mpickering

Subscribers: alanz, rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit 9a57cfebd2e65109884712a27a0f29d1a71f57b7)

17 months agoHaddock needs to pass visible modules for instance filtering
Alec Theriault [Fri, 26 Jan 2018 18:05:31 +0000 (13:05 -0500)] 
Haddock needs to pass visible modules for instance filtering

The GHC-side `getNameToInstancesIndex` filters out incorrectly some
instances because it is not aware of what modules are visible. Using
`runTcInteractive` means that `ie_visible` gets initialized to a one
module set containing some dummy GHCi module. This is clearly not the
module set we want to check against to see if a given orphan instance
is visible or not.

In fact, GHC has no way of knowing what we want that module set to be
since it doesn't know ahead of time which modules Haddock is making its
docs for. The fix is just to pass that set in as an argument.

Bumps haddock submodule.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: duog, alexbiehl, rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit a47438e88e685971a81874565f2914043c8233c3)

17 months agotestsuite: Fix test output broken by efba054640d3
Ben Gamari [Thu, 1 Feb 2018 04:02:52 +0000 (23:02 -0500)] 
testsuite: Fix test output broken by efba054640d3

Looks right to me.

(cherry picked from commit 7d9812e8f4e8723c94a8ee9f7ba629ac9f1d4e71)

17 months agotestsuite: Fix test output of T14715
Ben Gamari [Thu, 1 Feb 2018 03:53:16 +0000 (22:53 -0500)] 
testsuite: Fix test output of T14715

Arguably the warning should just be disabled for this test to eliminate
unnecessary wiggle in the future.

(cherry picked from commit fe6fdf689853f5d6e4ef01ba9952e4be48a92f45)

17 months agoDon't add targets that can't be found in GHCi
Julian Priestley [Thu, 1 Feb 2018 02:35:00 +0000 (21:35 -0500)] 
Don't add targets that can't be found in GHCi

When using the :add command in haxlsh/ghci, a module/file that can't
be found is still added to the list of targets, resulting in an error
message for the bad module/file for every subsequent usage of the
command. The add command should verify that the module/file can be
found before adding it to the list of targets.

Also add a ":show targets" command to show the currently added list of
commands, and an ":unadd" command to remove a target.

Test Plan:
Add a new GHCi testcase that checks that :add doesn't remember either
files or modules that could not be found, and that both the new :show
and :unadd commands work as expected.

Reviewers: simonmar, bgamari

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14676

Differential Revision:

(cherry picked from commit 0bff9e677f0569bc8a7207c20cddddfd67e2448f)

17 months agoMark xmm6 as caller saved in the register allocator for windows. [Thu, 1 Feb 2018 02:39:19 +0000 (21:39 -0500)] 
Mark xmm6 as caller saved in the register allocator for windows.

This prevents the register being picked up as a scratch register.
Otherwise the allocator would be free to use it before a call. This
fixes #14619.

Test Plan: ci, repro case on #14619

Reviewers: bgamari, Phyx, erikd, simonmar, RyanGlScott, simonpj

Reviewed By: Phyx, RyanGlScott, simonpj

Subscribers: simonpj, RyanGlScott, Phyx, rwbarton, thomie, carter

GHC Trac Issues: #14619

Differential Revision:

(cherry picked from commit add4e1f11b88cd603f6c01bc135eb576e1922a8e)

17 months agorts: Ensure that forkOS releases Task on termination
Ben Gamari [Thu, 1 Feb 2018 02:37:21 +0000 (21:37 -0500)] 
rts: Ensure that forkOS releases Task on termination

Test Plan: validate

Reviewers: simonmar, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14725

Differential Revision:

(cherry picked from commit 382c12d18f3d64e01502a5c8bbc64d4aa4842e3e)

17 months agoSysTools: Add detection support for LLD linker
Ben Gamari [Sun, 21 Jan 2018 18:31:29 +0000 (13:31 -0500)] 
SysTools: Add detection support for LLD linker

I noticed while trying to test against LLVM 5.0 that GHC would throw "Couldn't
figure out linker information" warnings due to LLD being chosen by configure.
Adding detection support to silence these is simple enough, let's just do it.

(cherry picked from commit 6c0db98bc5d1dceb8fa48544532f85d386900e4a)

17 months agoLook inside implications in simplifyRule
Simon Peyton Jones [Wed, 31 Jan 2018 14:25:50 +0000 (14:25 +0000)] 
Look inside implications in simplifyRule

Trac #14732 was a perpelexing bug in which -fdefer-typed-holes
caused a mysterious type error in a RULE.  This turned out to
be because we are more aggressive about creating implications
when deferring (see TcUnify.implicationNeeded), and the rule
mechanism hadn't caught up.

This fixes it.

(cherry picked from commit e9ae0cae9eb6a340473b339b5711ae76c6bdd045)

17 months agoPrioritise equalities when solving, incl deriveds
Simon Peyton Jones [Wed, 31 Jan 2018 13:05:13 +0000 (13:05 +0000)] 
Prioritise equalities when solving, incl deriveds

We already prioritise equalities when solving, but
Trac #14723 showed that we were not doing so consistently
enough, and as a result the type checker could go into a loop.

See Note [Prioritise equalities] in TcSMonad.

Fixng this bug changed the solve order enough to demonstrate
a problem with fundeps: Trac #14745.

(cherry picked from commit efba054640d3418d7477316ae0c1e992d0aa0f22)

17 months agoMove zonkWC to the right place in simplfyInfer
Simon Peyton Jones [Wed, 31 Jan 2018 11:35:33 +0000 (11:35 +0000)] 
Move zonkWC to the right place in simplfyInfer

runTcSWithEvBinds does some unification, so the zonkWC
must be after, not before!  Yikes.  An outright bug.

This fixes Trac #14715.

(cherry picked from commit e7c3878dacbad8120aacbe4423857b5ca9b43eb4)

17 months agoBump pretty submodule
Ben Gamari [Mon, 29 Jan 2018 06:28:13 +0000 (01:28 -0500)] 
Bump pretty submodule

17 months agoFix #14719 by using the setting the right SrcSpan
Ryan Scott [Fri, 26 Jan 2018 18:10:26 +0000 (13:10 -0500)] 
Fix #14719 by using the setting the right SrcSpan

Currently, error messages that germane to GADT constructors
put the source span at only the first character in the constructor,
leading to insufficient caret diagnostics. This can be easily fixed
by using a source span that spans the entire constructor, instead of
just the first character.

Test Plan: make test TEST=T14719

Reviewers: alanz, bgamari, simonpj

Reviewed By: alanz, simonpj

Subscribers: simonpj, goldfire, rwbarton, thomie, carter

GHC Trac Issues: #14719

Differential Revision:

(cherry picked from commit 59fa7b32b018a91f81773ca676251a0b2761ef56)

17 months agoFix Windows stack allocations.
Tamar Christina [Fri, 26 Jan 2018 18:10:10 +0000 (13:10 -0500)] 
Fix Windows stack allocations.

On Windows we use the function `win32AllocStack` to do stack
allocations in 4k blocks and insert a stack check afterwards
to ensure the allocation returned a valid block.

The problem is this function does something that by C semantics
is pointless. The stack allocated value can never escape the
function, and the stack isn't used so the compiler just optimizes
away the entire function body.

After considering a bunch of other possibilities I think the simplest
fix is to just disable optimizations for the function.

Alternatively inline assembly is an option but the stack check function
doesn't have a very portable name as it relies on e.g. `libgcc`.

Thanks to Sergey Vinokurov for helping diagnose and test.

Test Plan: ./validate

Reviewers: bgamari, erikd, simonmar

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14669

Differential Revision:

(cherry picked from commit a55d581f8f2923560c3444253050b13fdf2dec10)

17 months agoAdd ptr-eq short-cut to `compareByteArrays#` primitive
Herbert Valerio Riedel [Fri, 26 Jan 2018 18:07:17 +0000 (13:07 -0500)] 
Add ptr-eq short-cut to `compareByteArrays#` primitive

This is an obvious optimisation whose overhead is neglectable but
which significantly simplifies the common uses of `compareByteArrays#`
which would otherwise require to make *careful* use of
`reallyUnsafePtrEquality#` or (equally fragile) `byteArrayContents#`
which can result in less optimal assembler code being generated.

Test Plan: carefully examined generated cmm/asm code; validate via phab

Reviewers: alexbiehl, bgamari, simonmar

Reviewed By: bgamari, simonmar

Subscribers: rwbarton, thomie, carter

Differential Revision:

(cherry picked from commit 31c260f3967d2c06063c962a98475058daa45c6d)

17 months agoBump filepath submodule
Ben Gamari [Tue, 23 Jan 2018 06:09:52 +0000 (01:09 -0500)] 
Bump filepath submodule

17 months agoBump process submodule
Ben Gamari [Tue, 23 Jan 2018 06:09:34 +0000 (01:09 -0500)] 
Bump process submodule

17 months agoFix #14692 by correcting an off-by-one error in TcGenDeriv
Ryan Scott [Sun, 21 Jan 2018 17:06:06 +0000 (12:06 -0500)] 
Fix #14692 by correcting an off-by-one error in TcGenDeriv

A silly mistake in `gen_Show_binds` was causing derived
`Show` instances for empty data types to case on the precedence
argument instead of the actual value being showed.

Test Plan: make test TEST=drv-empty-data

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14692

Differential Revision:

(cherry picked from commit 0074a08ea9dfd1416aa57a9504be73dcdf7a1e2b)

17 months agoAdd new mbmi and mbmi2 compiler flags
John Ky [Sun, 21 Jan 2018 16:55:45 +0000 (11:55 -0500)] 
Add new mbmi and mbmi2 compiler flags

This adds support for the bit deposit and extraction operations provided
by the BMI and BMI2 instruction set extensions on modern amd64 machines.

Implement x86 code generator for pdep and pext.  Properly initialise
bmiVersion field.

pdep and pext test cases

Fix pattern match for pdep and pext instructions

Fix build of pdep and pext code for 32-bit architectures

Test Plan: Validate

Reviewers: austin, simonmar, bgamari, angerman

Reviewed By: bgamari

Subscribers: trommler, carter, angerman, thomie, rwbarton, newhoggy

GHC Trac Issues: #14206

Differential Revision:

(cherry picked from commit f855769690eb998ea25818ee794714957852af48)

17 months agotentative improvement to callstack docs
Alp Mestanogullari [Sun, 21 Jan 2018 17:07:58 +0000 (12:07 -0500)] 
tentative improvement to callstack docs

This is an attempt at clarifying the docs for HasCallStack in both the
user guide and libraries/base/GHC/Stack/Types.hs. The example used right
now is built around an hypothetical 'error' function that doesn't itself
print call stacks, and the fact that this doesn't hold makes it all
confusing, see #14635.

Reviewers: hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14635

Differential Revision:

17 months agoBump terminfo submodule
Ben Gamari [Mon, 22 Jan 2018 03:18:24 +0000 (22:18 -0500)] 
Bump terminfo submodule

17 months agoUpdate Cabal submodule
Oleg Grenrus [Sun, 21 Jan 2018 18:37:17 +0000 (20:37 +0200)] 
Update Cabal submodule

- Cabal-2.2 uses SPDX license identifiers, so I had to update
  `cabal-version: 2.1` packages `license: BSD3` to
  `license: BSD-3-Clause`
- `ghc-cabal` used old ReadP parsec, now it uses `parsec` too
- InstalledPackageInfo pretty-printing have changed a little,
  fields with default values aren't printed. This can be changed in
  `Cabal` still, but I haven't found problems with omitting them.

Note: `BSD-3-Clause` is parsed as "name = BSD, version = 3" by old
parser (because 3-Clause looks like version 3 with tag Clause).
If you see *"BSD-3" is not a valid license*, then something is using
old parser still.

Fixes #9885.

(cherry picked from commit 5d6e0806c690ac1958e4cbf609bc6b18048fb761)

17 months agoFix #14681 and #14682 with precision-aimed parentheses ghc-8.4.1-alpha2
Ryan Scott [Thu, 18 Jan 2018 16:06:42 +0000 (11:06 -0500)] 
Fix #14681 and #14682 with precision-aimed parentheses

It turns out that `Convert` was recklessly leaving off
parentheses in two places:

* Negative numeric literals
* Patterns in lambda position

This patch fixes it by adding three new functions, `isCompoundHsLit`,
`isCompoundHsOverLit`, and `isCompoundPat`, and using them in the
right places in `Convert`. While I was in town, I also sprinkled
`isCompoundPat` among some `Pat`-constructing functions in `HsUtils`
to help avoid the likelihood of this problem happening in other
places. One of these places is in `TcGenDeriv`, and sprinkling
`isCompountPat` there fixes #14682

Test Plan: make test TEST="T14681 T14682"

Reviewers: alanz, goldfire, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14681, #14682

Differential Revision:

(cherry picked from commit 575c009d9e4b25384ef984c09b2c54f909693e93)

17 months agoRemove executable filename check on windows [Mon, 15 Jan 2018 18:52:15 +0000 (13:52 -0500)] 
Remove executable filename check on windows

On Windows GHC enforces currently that the real executable is named

I don't see a good reason why this is neccessary.
This patch removes this restriction and fixes #14652

Test Plan: ci

Reviewers: bgamari, Phyx

Reviewed By: Phyx

Subscribers: Phyx, rwbarton, thomie, carter

GHC Trac Issues: #14652

Differential Revision:

(cherry picked from commit 1bf70b2041dc2b7c89565fcb46cad8f151f96790)

17 months agoFix hash in haddock of ghc-prim.
HE, Tao [Mon, 15 Jan 2018 18:51:15 +0000 (13:51 -0500)] 
Fix hash in haddock of ghc-prim.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14653

Differential Revision:

(cherry picked from commit 2feed118413944cae8a4eed17365f40521f470db)

17 months agoInform hole substitutions of typeclass constraints (fixes #14273).
Matthías Páll Gissurarson [Thu, 18 Jan 2018 05:49:38 +0000 (00:49 -0500)] 
Inform hole substitutions of typeclass constraints (fixes  #14273).

This implements SPJ's suggestion on the ticket (#14273). We find the
relevant constraints (ones that whose free unification variables are all
mentioned in the type of the hole), and then clone the free unification
variables of the hole and the relevant constraints. We then add a
subsumption constraints and run the simplifier, and then check whether
all the constraints were solved.

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: RyanGlScott, rwbarton, thomie, carter

GHC Trac Issues: #14273

Differential Revision:

(cherry picked from commit 1e14fd3ecfd468c3beddb2e5f992c358e1a798de)

17 months agoImprove treatment of sectioned holes
Ryan Scott [Thu, 21 Dec 2017 00:25:53 +0000 (19:25 -0500)] 
Improve treatment of sectioned holes

Previously, GHC was pretty-printing left-section holes
incorrectly and not parsing right-sectioned holes at all. This patch
fixes both problems.

Test Plan: make test TEST=T14590

Reviewers: bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie, mpickering, carter

GHC Trac Issues: #14590

Differential Revision:

(cherry picked from commit 4d41e9212d1fdf109f2d0174d204644446f5874c)