ghc.git
4 months agoAPI Annotations: parens anns discarded for `(*)` operator wip/ghc-8.8-az
Alan Zimmerman [Sat, 2 Feb 2019 14:29:05 +0000 (16:29 +0200)] 
API Annotations: parens anns discarded for `(*)` operator

The patch from https://phabricator.haskell.org/D4865 introduces

    go _ (HsParTy _ (dL->L l (HsStarTy _ isUni))) acc ann fix
      = do { warnStarBndr l
           ; let name = mkOccName tcClsName (if isUni then "★" else "*")
           ; return (cL l (Unqual name), acc, fix, ann) }

which discards the parens annotations belonging to the HsParTy.

Updates haddock submodule

Closes #16265

(cherry picked from commit 5e9888bd9c22a1315a703f638591b50e657317c4)

4 months agoAPI Annotations: AnnAt disconnected for TYPEAPP
Alan Zimmerman [Wed, 30 Jan 2019 14:20:52 +0000 (16:20 +0200)] 
API Annotations: AnnAt disconnected for TYPEAPP

For the code

    type family F1 (a :: k) (f :: k -> Type) :: Type where
      F1 @Peano a f = T @Peano f a

the API annotation for the first @ is not attached to a SourceSpan in
the ParsedSource

Closes #16236

(cherry picked from commit cbfc9fcaa33c3b341830962906543dfca1dfedd7)

4 months agoAPI Annotations: more explicit foralls fixup
Alan Zimmerman [Thu, 24 Jan 2019 21:22:59 +0000 (23:22 +0200)] 
API Annotations: more explicit foralls fixup

The AnnForall annotations introduced via Phab:D4894 are not always
attached to the correct SourceSpan.

Closes #16230

(cherry picked from commit be15f7457b98fa0378de7e8146c122757f03c4e9)

4 months agoAPI Annotations: Parens not attached correctly for ClassDecl
Alan Zimmerman [Thu, 24 Jan 2019 08:14:55 +0000 (10:14 +0200)] 
API Annotations: Parens not attached correctly for ClassDecl

The parens around the kinded tyvars should be attached to the class
declaration as a whole, they are attached to the tyvar instead,
outside the span.

An annotation must always be within or after the span it is contained
in.

Closes #16212

(cherry picked from commit 4bf35da4fccd2a21153a1c19bfa80006e99e02a1)

4 months agocheck-api-annotations checks for annotation preceding its span
Alan Zimmerman [Tue, 22 Jan 2019 21:29:25 +0000 (23:29 +0200)] 
check-api-annotations checks for annotation preceding its span

For an API annotation to be useful, it must not occur before the span
it is enclosed in.

So, for check-api-annotation output, a line such as

((Test16212.hs:3:22-36,AnnOpenP), [Test16212.hs:3:21]),

should be flagged as an error, as the AnnOpenP location of 3:21
precedes its enclosing span of 3:22-26.

This patch does this.

Closes #16217

(cherry picked from commit 3cf12e6081e7a9f0c3d515de52ffd079186816a5)

4 months agoBump hsc2hs for removed unused match
Sebastian Graf [Fri, 1 Feb 2019 11:43:27 +0000 (12:43 +0100)] 
Bump hsc2hs for removed unused match

4 months agoBump Cabal submodule wip/hie-8.8
Ben Gamari [Tue, 26 Feb 2019 18:05:26 +0000 (13:05 -0500)] 
Bump Cabal submodule

4 months agoLexer: Alternate Layout Rule injects actual not virtual braces
Alan Zimmerman [Sun, 3 Feb 2019 08:27:42 +0000 (10:27 +0200)] 
Lexer: Alternate Layout Rule injects actual not virtual braces

When the alternate layout rule is activated via a pragma, it injects
tokens for { and } to make sure that the source is parsed properly.

But it injects ITocurly and ITccurly, rather than their virtual
counterparts ITvocurly and ITvccurly.

This causes problems for ghc-exactprint, which tries to print these.

Likewise, any injected ITsemi should have a zero-width SrcSpan.

Test case (the existing T13087.hs)

    {-# LANGUAGE AlternativeLayoutRule #-}
    {-# LANGUAGE LambdaCase            #-}

    isOne :: Int -> Bool
    isOne = \case 1 -> True
                  _ -> False

    main = return ()

Closes #16279

(cherry picked from commit c1cf2693d6efddeeeb813cd8995a1be136800d17)
(cherry picked from commit e0375ba980fd5639d23a29575efb00c30d97c743)

4 months agoRevert "Lexer: Alternate Layout Rule injects actual not virtual braces"
Ben Gamari [Tue, 26 Feb 2019 17:57:57 +0000 (12:57 -0500)] 
Revert "Lexer: Alternate Layout Rule injects actual not virtual braces"

This reverts commit e0375ba980fd5639d23a29575efb00c30d97c743.

4 months agoProperly escape character literals in Haddocks
Alec Theriault [Wed, 13 Feb 2019 13:43:35 +0000 (08:43 -0500)] 
Properly escape character literals in Haddocks

Character literals in Haddock should not be written as plain `'\n'` since
single quotes are for linking identifiers. Besides, since we want the
character literal to be monospaced, we really should use `@\'\\n\'@`.

[skip ci]

4 months agotemplate-haskell: Document assembler foreign file support
Ben Gamari [Wed, 20 Feb 2019 19:38:05 +0000 (14:38 -0500)] 
template-haskell: Document assembler foreign file support

See #16180.

4 months agoFix #16188
Richard Eisenberg [Fri, 18 Jan 2019 00:17:02 +0000 (17:17 -0700)] 
Fix #16188

There was an awful lot of zipping going on in
canDecomposableTyConAppOK, and one of the lists being zipped
was too short, causing the result to be too short. Easily
fixed.

Also fixes #16204 and #16225

test case: typecheck/should_compile/T16188
           typecheck/should_compile/T16204[ab]
           typecheck/should_fail/T16204c
           typecheck/should_compile/T16225

(cherry picked from commit 4a4ae70f09009c5d32696445a06eacb273f364b5)

4 months agoAllow resizing the stack for the graph allocator.
klebinger.andreas@gmx.at [Fri, 25 Jan 2019 23:26:02 +0000 (00:26 +0100)] 
Allow resizing the stack for the graph allocator.

The graph allocator now dynamically resizes the number of stack
slots when running into the limit.

This fixes #8657.

Also loop membership of basic blocks is now available
in the register allocator for cost heuristics.

(cherry picked from commit 03b7abc19c8b0ec5c606cc2da208d2d004807fe9)

4 months agoCapture and simplify constraints arising from running typed splices
Matthew Pickering [Sun, 3 Feb 2019 11:46:28 +0000 (11:46 +0000)] 
Capture and simplify constraints arising from running typed splices

This fixes a regression caused by #15471 where splicing in a trivial
program such as `[|| return () ||]` would fail as the dictionary for
`return` would never get bound in the module containing the splice.

Arguably this is symptomatic of a major problem affecting TTH where we
serialise renamed asts and then retype check them. The reference to the
dictionary should be fully determined at the quote site so that splicing
doesn't have to solve any implicits at all. It's a coincidence this
works due to coherence but see #15863 and #15865 for examples where
things do go very wrong.

Fixes #16195

(cherry picked from commit a48753bdbc99cda36890e851950f5b79e1c3b2b2)

4 months agoFix #14729 by making the normaliser homogeneous
Richard Eisenberg [Thu, 24 Jan 2019 15:22:58 +0000 (10:22 -0500)] 
Fix #14729 by making the normaliser homogeneous

This ports the fix to #12919 to the normaliser. (#12919 was about
the flattener.) Because the fix is involved, this is done by
moving the critical piece of code to Coercion, and then calling
this from both the flattener and the normaliser.

The key bit is: simplifying type families in a type is always
a *homogeneous* operation. See #12919 for a discussion of why
this is the Right Way to simplify type families.

Also fixes #15549.

test case: dependent/should_compile/T14729{,kind}
           typecheck/should_compile/T15549[ab]

(cherry picked from commit 2b90356d26b4699227816ad9424e766eccdb6c36)

4 months agoFix #15849 by checking whether there's a do block
nineonine [Sat, 9 Feb 2019 08:20:19 +0000 (00:20 -0800)] 
Fix #15849 by checking whether there's a do block

(cherry picked from commit a08f463bcc9727d91cec4c6e952ad0f5bbc3fbf9)

4 months agotestsuite: Always skip T15897
Ben Gamari [Tue, 5 Feb 2019 03:02:52 +0000 (22:02 -0500)] 
testsuite: Always skip T15897

See #16193.

(cherry picked from commit f53ef1a72fdebeff19d4a4bd5552d25101c85147)

4 months agoUse sigPrec in more places in Convert and HsUtils
Ryan Scott [Tue, 15 Jan 2019 02:45:17 +0000 (21:45 -0500)] 
Use sigPrec in more places in Convert and HsUtils

Trac #16183 was caused by TH conversion (in `Convert`) not properly
inserting parentheses around occurrences of explicit signatures where
appropriate, such as in applications, function types, and type family
equations. Solution: use `parenthesizeHsType sigPrec` in these
places. While I was in town, I also updated `nlHsFunTy` to do the
same thing.

(cherry picked from commit b1e569a54085bf1093b4f858f8c7c739e3be769b)

4 months agoReject oversaturated VKAs in type family equations
Ryan Scott [Sat, 2 Feb 2019 00:10:55 +0000 (19:10 -0500)] 
Reject oversaturated VKAs in type family equations

(cherry picked from commit f0cd728fde9bb582930a616cff8d0c5a178c5e14)

4 months agoLexer: Alternate Layout Rule injects actual not virtual braces
Alan Zimmerman [Sun, 3 Feb 2019 08:27:42 +0000 (10:27 +0200)] 
Lexer: Alternate Layout Rule injects actual not virtual braces

When the alternate layout rule is activated via a pragma, it injects
tokens for { and } to make sure that the source is parsed properly.

But it injects ITocurly and ITccurly, rather than their virtual
counterparts ITvocurly and ITvccurly.

This causes problems for ghc-exactprint, which tries to print these.

Likewise, any injected ITsemi should have a zero-width SrcSpan.

Test case (the existing T13087.hs)

    {-# LANGUAGE AlternativeLayoutRule #-}
    {-# LANGUAGE LambdaCase            #-}

    isOne :: Int -> Bool
    isOne = \case 1 -> True
                  _ -> False

    main = return ()

Closes #16279

(cherry picked from commit c1cf2693d6efddeeeb813cd8995a1be136800d17)

4 months agoFix #16287 by checking for more unsaturated synonym arguments
Ryan Scott [Tue, 5 Feb 2019 13:50:59 +0000 (08:50 -0500)] 
Fix #16287 by checking for more unsaturated synonym arguments

Trac #16287 shows that we were checking for unsaturated type synonym
arguments (in `:kind`) when the argument was to a type synonym, but
_not_ when the argument was to some other form of type constructor,
such as a data type. The solution is to use the machinery that
rejects unsaturated type synonym arguments (previously confined to
`check_syn_tc_app`) to `check_arg_type`, which checks these other
forms of arguments. While I was in town, I cleaned up
`check_syn_tc_app` a bit to only invoke `check_arg_type` so as to
minimize the number of different code paths that that function could
go down.

(cherry picked from commit c07e7ecbdfc05429fb6ce84c547c0365d2754db7)

4 months agobase: Document errno behaviour in haddocks.
Niklas Hambüchen [Thu, 14 Feb 2019 21:52:17 +0000 (16:52 -0500)] 
base: Document errno behaviour in haddocks.

Also add an implementation comment for details.

(cherry picked from commit 76ac103f5021cba5cd000293c7cb8c2bd3148e7a)

4 months agoHIE: Save module name and module exports
Matthew Pickering [Fri, 15 Feb 2019 10:14:29 +0000 (10:14 +0000)] 
HIE: Save module name and module exports

(cherry picked from commit 69ebf5cb4592b4c89e268937ef7eb96f7c9d4532)

4 months agorts/ProfilerReportJson: Fix format string
Ben Gamari [Tue, 5 Feb 2019 02:42:41 +0000 (21:42 -0500)] 
rts/ProfilerReportJson: Fix format string

This was warning on i386.

(cherry picked from commit 7ff127f9e455402da183d1bb1808db024d1fa944)

4 months agoInclude type info for only some exprs in HIE files
Alec Theriault [Fri, 25 Jan 2019 01:33:52 +0000 (17:33 -0800)] 
Include type info for only some exprs in HIE files

This commit relinquishes some some type information in `.hie` files in
exchange for better performance. See #16233 for more on this.

Using `.hie` files to generate hyperlinked sources is a crucial milestone
towards Hi Haddock (the initiative to move Haddock to work over `.hi`
files and embed docstrings in those). Unfortunately, even after much
optimization on the Haddock side, the `.hie` based solution is still
considerably slower and more memory hungry than the existing implementation
- and the @.hie@ code is to blame.

This changes `.hie` file generation to track type information for only
a limited subset of expressions (specifically, those that might eventually
turn into hyperlinks in the Haddock's hyperlinker backend).

(cherry picked from commit 5ed48d25decc9dec29659482644b136cff91606e)

4 months agoPPC NCG: Promote integers to word size in C calls
Peter Trommler [Wed, 23 Jan 2019 22:13:57 +0000 (23:13 +0100)] 
PPC NCG: Promote integers to word size in C calls

Fixes #16222

(cherry picked from commit 4376d8811418d91bb4d19d61801e95a449b98378)

4 months agomake ghc-pkg shut up
Moritz Angermann [Wed, 23 Jan 2019 02:59:38 +0000 (10:59 +0800)] 
make ghc-pkg shut up

(cherry picked from commit f00b35f4ddcc61fb1b1f09854bbbf38934ff0865)

4 months agogitlab-ci: Use build cleanup logic on Darwin as well
Ben Gamari [Mon, 21 Jan 2019 15:55:48 +0000 (10:55 -0500)] 
gitlab-ci: Use build cleanup logic on Darwin as well

We use the shell executor on Darwin as well as Windows.
See https://gitlab.com/gitlab-org/gitlab-runner/issues/3856.

(cherry picked from commit cfbd39bd405b4cedd3ee10a6d4a2bdd89b6e2e2d)

4 months agogitlab-ci: Fix Windows cleanup command line
Ben Gamari [Wed, 23 Jan 2019 15:09:49 +0000 (10:09 -0500)] 
gitlab-ci: Fix Windows cleanup command line

Why is it so hard to delete a directory's contents without deleting the
directory itself in Windows? This will forever remain a mystery.

(cherry picked from commit 6da9f4c8df7a216234ef50104e400cdcbfbc1bd4)

4 months agoTest that hsc2hs works with promoted data constructors
Andrew Martin [Mon, 21 Jan 2019 21:04:30 +0000 (16:04 -0500)] 
Test that hsc2hs works with promoted data constructors

(cherry picked from commit 79a5afb613235e93bc2c580987595b9c1324db15)

4 months agoFix incorrectly named configure options
Alec Theriault [Sun, 27 Jan 2019 02:07:48 +0000 (18:07 -0800)] 
Fix incorrectly named configure options

Although we should use 'AC_ARG_ENABLE' for boolean flags, it also
means options get named '--enable-*', not '--with-*'. This should
unbreak the --with-intree-gmp option.

(cherry picked from commit b89b6e71c798996724ba99f273f88d8a3637fb8d)

4 months agohadrian: use new-exec to make sure alex & happy are in PATH (#16120)
Adam Sandberg Eriksson [Wed, 2 Jan 2019 21:08:49 +0000 (22:08 +0100)] 
hadrian: use new-exec to make sure alex & happy are in PATH (#16120)

(cherry picked from commit 5cb071af5b02b7433b2bb4d06062ac8b6fb387e8)

4 months agotestsuite: Mark hWaitForInput-accurate-socket as requiring unix
Ben Gamari [Wed, 23 Jan 2019 18:06:45 +0000 (13:06 -0500)] 
testsuite: Mark hWaitForInput-accurate-socket as requiring unix

It imports System.Posix.IO.

4 months agotestsuite: Remove directories that already exist when seeding extra_files
Ben Gamari [Mon, 21 Jan 2019 03:36:22 +0000 (22:36 -0500)] 
testsuite: Remove directories that already exist when seeding extra_files

Otherwise the testsuite driver crashes when run multiple times with CLEANUP=NO
on a test containing such extra_files.

4 months agotestsuite: Normalise style
Ben Gamari [Mon, 21 Jan 2019 03:32:09 +0000 (22:32 -0500)] 
testsuite: Normalise style

4 months agoGhcPlugins: Fix lookup of TH names
Ben Gamari [Sat, 19 Jan 2019 18:59:18 +0000 (13:59 -0500)] 
GhcPlugins: Fix lookup of TH names

Previously `thNameToGhcName` was calling `lookupOrigNameCache` directly, which
failed to handle the case that the name wasn't already in the name cache. This
happens, for instance, when the name was in scope in a plugin being used during
compilation but not in scope in the module being compiled. In this case we the
interface file containing the name won't be loaded and `lookupOrigNameCache`
fails. This was the cause of #16104.

The solution is simple: use the nicely packaged `lookupOrigIO` instead.

4 months agotestsuite: Add test for #16104
Ben Gamari [Tue, 15 Jan 2019 16:48:59 +0000 (11:48 -0500)] 
testsuite: Add test for #16104

4 months agotestsuite: Add predicate for CPU feature availability
Ben Gamari [Thu, 27 Dec 2018 19:41:01 +0000 (14:41 -0500)] 
testsuite: Add predicate for CPU feature availability

Previously testing code-generation for ISA extensions was nearly impossible
since we had no ability to determine whether the host supports the needed
extension. Here we fix this by introducing a simple /proc/cpuinfo-based
testsuite predicate. We really ought to

4 months agoAdd @sgraf to CODEOWNERS
Sebastian Graf [Sat, 26 Jan 2019 17:44:23 +0000 (12:44 -0500)] 
Add @sgraf to CODEOWNERS

[skip ci]

4 months agoAdd Simon and Richard as more CODEOWNERS
Richard Eisenberg [Fri, 25 Jan 2019 03:27:00 +0000 (22:27 -0500)] 
Add Simon and Richard as more CODEOWNERS

[skip ci]

4 months agogitlab-ci: Explicitly clear dependencies of all jobs
Ben Gamari [Tue, 22 Jan 2019 19:21:31 +0000 (14:21 -0500)] 
gitlab-ci: Explicitly clear dependencies of all jobs

Apparently GitLab CI defaults to declaring all jobs of the previous
stage as dependencies of a job. This meant that we would end up
downloading all of our binary distributions during the `cleanup` stage,
eating up a truly remarkable amount of S3 tranfers.

4 months agotestsuite: Skip ghcilink002 when unregisterised
Ben Gamari [Tue, 22 Jan 2019 23:40:36 +0000 (18:40 -0500)] 
testsuite: Skip ghcilink002 when unregisterised

See #16085.

4 months agoMinor refactor [ci skip]
Gabor Greif [Tue, 22 Jan 2019 11:13:28 +0000 (12:13 +0100)] 
Minor refactor [ci skip]

4 months agoA few typofixes
Gabor Greif [Tue, 22 Jan 2019 11:07:47 +0000 (12:07 +0100)] 
A few typofixes

4 months agogitlab-ci: Drop CircleCI jobs
Ben Gamari [Tue, 22 Jan 2019 19:25:05 +0000 (14:25 -0500)] 
gitlab-ci: Drop CircleCI jobs

It's pretty unlikely we will be going back to circleci at this point

[skip-ci]

4 months agoError out of invalid Int/Word bit shifts
Alec Theriault [Fri, 11 Jan 2019 07:44:04 +0000 (23:44 -0800)] 
Error out of invalid Int/Word bit shifts

Although the Haddock's for `shiftL` and `shiftR` do require the number
of bits to be non-negative, we should still check this before calling
out to primitives (which also have undefined behaviour for negative bit
shifts).

If a user _really_ wants to bypass checks that the number of bits is
sensible, they already have the aptly-named `unsafeShiftL`/`unsafeShiftR`
at their disposal.

See #16111.

4 months agogitlab: Collect artifacts on Windows
Ben Gamari [Wed, 16 Jan 2019 04:21:39 +0000 (23:21 -0500)] 
gitlab: Collect artifacts on Windows

4 months agoUpdate Darwin CI to use new toplevel --with-intree-gmp configure flag
Alec Theriault [Tue, 22 Jan 2019 03:25:29 +0000 (19:25 -0800)] 
Update Darwin CI to use new toplevel --with-intree-gmp configure flag

4 months agoHadrian: support in-tree GMP
Alec Theriault [Thu, 6 Dec 2018 04:46:21 +0000 (20:46 -0800)] 
Hadrian: support in-tree GMP

Summary:
This adds top-level configure flags '--with-intree-gmp' and
'--with-framework-preferred', both of which are especially relevant
on MacOS.

Besides gaining two new flags, Hadrian also had to be taught what to
do with the 'framework' in .cabal files.

Test Plan:
./boot && ./configure --with-intree-gmp && ./hadrian/build.sh
./boot && ./configure --with-gmp-framework-preferred && ./hadrian/build.sh # on macos

Reviewers: carter, snowleopard, alpmestan, hvr, goldfire, bgamari

Subscribers: rwbarton, erikd

GHC Trac Issues: #16001

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

4 months agogitlab-ci: Disallow failure
Ben Gamari [Thu, 17 Jan 2019 18:56:00 +0000 (13:56 -0500)] 
gitlab-ci: Disallow failure

4 months agotestsuite: Mark T16180 as broken on Darwin
Ben Gamari [Wed, 23 Jan 2019 00:08:07 +0000 (19:08 -0500)] 
testsuite: Mark T16180 as broken on Darwin

See #16218.

4 months agotestsuite: Mark ghci063 as broken on Darwin
Ben Gamari [Thu, 17 Jan 2019 18:55:00 +0000 (13:55 -0500)] 
testsuite: Mark ghci063 as broken on Darwin

This is the last failing test on Darwin preventing us from disallowing CI
failures. See #16201.

4 months agoHadrian: install patches 'haddock-{html,interface}'
Alec Theriault [Sat, 19 Jan 2019 09:06:00 +0000 (01:06 -0800)] 
Hadrian: install patches 'haddock-{html,interface}'

Since the `$(docdir)` can be picked independently from the `$(libdir)`,
we need to make sure that that the `haddock-html` and `haddock-interface`
fields in the package DB (which is in the `$(libdir)`) get updated to
point to the appropriate places in the `$(docdir)`.

NB: in the make system, `ghc-cabal` would cover this sort of thing by
re-running `configure` on installation, but here we get away with a
couple lines of `sed` and a call to `ghc-pkg recache`.

Fixes #16202.

4 months agotestsuite: Ensure that config.{msys,cygwin} are initialized
Ben Gamari [Mon, 21 Jan 2019 01:45:34 +0000 (20:45 -0500)] 
testsuite: Ensure that config.{msys,cygwin} are initialized

Reviewers: monoidal

Reviewed By: monoidal

Subscribers: monoidal, rwbarton, carter

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

4 months agoAdd myself to CODEOWNERS for a few files
Joachim Breitner [Tue, 22 Jan 2019 09:57:52 +0000 (10:57 +0100)] 
Add myself to CODEOWNERS for a few files

4 months agoMinor typo in docs for KProxy
Joachim Breitner [Tue, 22 Jan 2019 10:17:57 +0000 (11:17 +0100)] 
Minor typo in docs for KProxy

really minor, but it annoyed me when reading it :-)

4 months agoFix hadrian prof flavour so that it builds a profiled version of GHC
Matthew Pickering [Tue, 22 Jan 2019 11:33:18 +0000 (11:33 +0000)] 
Fix hadrian prof flavour so that it builds a profiled version of GHC

In Alp's refactoring of `getProgramContexts` he removed a call to
`getProgramContext` which was where the logic for this used to be
implemented.

Fixes #16214

4 months agousers guide: fix typesetting of pragmas
Ben Price [Tue, 22 Jan 2019 00:16:14 +0000 (00:16 +0000)] 
users guide: fix typesetting of pragmas

4 months agousers guide: consistent spelling of inlinable
Ben Price [Tue, 22 Jan 2019 00:15:05 +0000 (00:15 +0000)] 
users guide: consistent spelling of inlinable

4 months agogitlab-ci: Reenable Hadrian build on Windows
Ben Gamari [Mon, 21 Jan 2019 20:55:05 +0000 (15:55 -0500)] 
gitlab-ci: Reenable Hadrian build on Windows

4 months agoUpdate transformers module
Herbert Valerio Riedel [Tue, 22 Jan 2019 00:00:10 +0000 (01:00 +0100)] 
Update transformers module

4 months agoFix bogus worker for newtypes
Simon Peyton Jones [Wed, 16 Jan 2019 16:34:24 +0000 (16:34 +0000)] 
Fix bogus worker for newtypes

The "worker" for a newtype is actually a function
with a small (compulsory) unfolding, namely a cast.

But the construction of this function was plain wrong
for newtype /instances/; it cast the arguemnt to the
family type rather than the representation type.

This never actually bit us because, in the case of a
family instance, we immediately cast the result to
the family type.  So we get
   \x. (x |> co1) |> co2

where the compositio of co1 and co2 is ill-kinded.
However the optimiser (even the simple optimiser)
just collapsed those casts, ignoring the mis-match
in the middle, so we never saw the problem.

Trac #16191 is indeed a dup of #16141; but the resaon
these tickets produce Lint errors is not the unnecessary
forcing; it's because of the ill-typed casts.

This patch fixes the ill-typed casts, properly.  I can't
see a way to trigger an actual failure prior to this
patch, but it's still wrong wrong wrong to have ill-typed
casts, so better to get rid of them.

4 months agoExtend linker-script workaround to work with musl libc
Samuel Holland [Mon, 21 Jan 2019 02:20:16 +0000 (20:20 -0600)] 
Extend linker-script workaround to work with musl libc

GHC has code to handle unsuffixed .so files that are linker scripts
pointing to the real shared library. The detection is done by parsing
the result of `dlerror()` after calling `dlopen()` and looking for
certain error strings. On musl libc, the error message is "Exec format
error", which happens to be `strerror(ENOEXEC)`:

```
$ cat tmp.c
#include <dlfcn.h>
#include <stdio.h>

int main(void) {
        dlopen("libz.so", RTLD_NOW | RTLD_GLOBAL);
        puts(dlerror());
        return 0;
}
$ gcc -o tmp tmp.c
$ ./tmp
Error loading shared library libz.so: Exec format error
$
```

This change fixes the workaround to also work on musl libc.

Link: https://phabricator.haskell.org/D5474
4 months agoAdd CODEOWNERS
Ben Gamari [Mon, 21 Jan 2019 19:42:13 +0000 (14:42 -0500)] 
Add CODEOWNERS

GitLab uses this file to suggest reviewers based upon the files that a Merge
Request touches.

[skip-ci]

4 months agogitlab: Add merge request template
Ben Gamari [Sat, 19 Jan 2019 20:47:33 +0000 (15:47 -0500)] 
gitlab: Add merge request template

This begins to define our expectations of contributions.

[skip-ci]

4 months agoFix typo in TcRnTypes.hs [skip ci]
Matthew Pickering [Mon, 21 Jan 2019 17:17:20 +0000 (12:17 -0500)] 
Fix typo in TcRnTypes.hs [skip ci]

4 months agoAdd support for ASM foreign files (.s) in TH (#16180)
Sylvain Henry [Tue, 15 Jan 2019 12:14:45 +0000 (13:14 +0100)] 
Add support for ASM foreign files (.s) in TH (#16180)

4 months agoRemove TODO in HsExpr
Matthew Pickering [Fri, 18 Jan 2019 16:36:12 +0000 (11:36 -0500)] 
Remove TODO in HsExpr

It is correct to be `GhcTc` as the data type is for expressions which are inside splices
so they can be delayed until desugaring.

4 months agoMention DerivingStrategies in the warning when DAC and GND are both enabled
Chaitanya Koparkar [Mon, 14 Jan 2019 19:36:29 +0000 (14:36 -0500)] 
Mention DerivingStrategies in the warning when DAC and GND are both enabled

Summary:

When DeriveAnyClass and GeneralizedNewtypeDeriving are both enabled,
GHC prints out a warning that specifies the strategy it used to
derive a class. This patch updates the warning to mention that users
may pick a particular strategy by using DerivingStrategies.

Test plan: make test TEST=T16179

4 months ago[T16199] Adds a verify-packages script
Moritz Angermann [Sun, 20 Jan 2019 10:24:21 +0000 (05:24 -0500)] 
[T16199] Adds a verify-packages script

4 months agoUphold AvailTC Invariant for associated data fams
Alec Theriault [Sat, 2 Feb 2019 00:26:43 +0000 (16:26 -0800)] 
Uphold AvailTC Invariant for associated data fams

The AvailTC was not be upheld for explicit export module
export lists when the module contains associated data families.

    module A (module A) where
    class    C a  where { data T a }
    instance C () where { data T () = D }

Used to (incorrectly) report avails as `[C{C, T;}, T{D;}]`. Note that
although `T` is exported, the avail where it is the parent does _not_
list it as its first element. This avail is now correctly listed as
`[C{C, T;}, T{T, D;}]`.

This was induces a [crash in Haddock][0].

See #16077.

[0]: https://github.com/haskell/haddock/issues/979

5 months agoPrepare source-tree for base-4.13 MFP bump
Herbert Valerio Riedel [Tue, 18 Dec 2018 22:36:29 +0000 (23:36 +0100)] 
Prepare source-tree for base-4.13 MFP bump

5 months agoFix typo in DsExpr
Matthew Pickering [Fri, 18 Jan 2019 13:35:08 +0000 (08:35 -0500)] 
Fix typo in DsExpr

5 months agoComments in stranal test declarations
Ömer Sinan Ağacan [Fri, 18 Jan 2019 08:51:59 +0000 (11:51 +0300)] 
Comments in stranal test declarations

6 months agoSmall refactor
Simon Peyton Jones [Thu, 10 Jan 2019 12:08:47 +0000 (12:08 +0000)] 
Small refactor

...to use the same error message rather than duplicating it

6 months agoRemove export of checkValidFamPats, never used
Simon Peyton Jones [Thu, 10 Jan 2019 12:08:15 +0000 (12:08 +0000)] 
Remove export of checkValidFamPats, never used

6 months agoComments about data constructor wrappers
Simon Peyton Jones [Thu, 10 Jan 2019 12:07:57 +0000 (12:07 +0000)] 
Comments about data constructor wrappers

6 months ago'DynFlag'-free version of 'mkParserFlags'
Alec Theriault [Tue, 8 Jan 2019 20:07:07 +0000 (12:07 -0800)] 
'DynFlag'-free version of 'mkParserFlags'

Summary:
This is a fixed version of the reverted d2fbc33c4ff3074126ab71654af8bbf8a46e4e11
and  5aa29231ab7603537284eff5e4caff3a73dba6d2.

Obtaining a `DynFlags` is difficult, making using the lexer/parser
for pure parsing/lexing unreasonably difficult, even with `mkPStatePure`.
This is despite the fact that we only really need

    * language extension flags
    * warning flags
    * a handful of boolean options

The new `mkParserFlags'` function makes is easier to directly construct a
`ParserFlags`. Furthermore, since `pExtsBitmap` is just a footgun, I've gone
ahead and made `ParserFlags` an abstract type.

Also, we now export `ExtBits` and `getBit` instead of defining/exporting a
bunch of boilerplate functions that test for a particular 'ExtBits'.
In the process, I also

  * cleaned up an unneeded special case for `ITstatic`
  * made `UsePosPrags` another variant of `ExtBits`
  * made the logic in `reservedSymsFM` match that of `reservedWordsFM`

Test Plan: make test

Reviewers: bgamari, alanz, tdammers

Subscribers: sjakobi, tdammers, rwbarton, mpickering, carter

GHC Trac Issues: #11301

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

6 months agoPPC NCG: Rename constructors
Peter Trommler [Thu, 3 Jan 2019 13:04:37 +0000 (14:04 +0100)] 
PPC NCG: Rename constructors

Rename constructors in calling convention data type to reflect the
fact that they represent an ELF ABI not only a Linux ABI.

6 months agoFix tab and improve whitespace
Peter Trommler [Sat, 29 Dec 2018 10:29:02 +0000 (11:29 +0100)] 
Fix tab and improve whitespace

6 months agoPPC NCG: Register definitions for all 64-bit systems
Peter Trommler [Sat, 29 Dec 2018 09:14:12 +0000 (10:14 +0100)] 
PPC NCG: Register definitions for all 64-bit systems

6 months agoPPC NCG: GOT declaration for all 64-bit ELF systems
Peter Trommler [Sat, 29 Dec 2018 09:12:48 +0000 (10:12 +0100)] 
PPC NCG: GOT declaration for all 64-bit ELF systems

6 months agoPPC NCG: Make `stackHeaderSize` more general
Peter Trommler [Fri, 28 Dec 2018 22:55:35 +0000 (23:55 +0100)] 
PPC NCG: Make `stackHeaderSize` more general

6 months agoPPC NCG: Make calling convention more general
Peter Trommler [Fri, 28 Dec 2018 22:52:31 +0000 (23:52 +0100)] 
PPC NCG: Make calling convention more general

All operating systems except AIX and Darwin follow the ELF
specification.

6 months agoRTS: Use ELF v1 convention on all powerpc64 systems
Peter Trommler [Fri, 28 Dec 2018 21:30:34 +0000 (22:30 +0100)] 
RTS: Use ELF v1 convention on all powerpc64 systems

6 months agoAdd test for #16197
Ömer Sinan Ağacan [Thu, 17 Jan 2019 13:57:20 +0000 (16:57 +0300)] 
Add test for #16197

6 months agoDocumentation for StgRetFun
Ömer Sinan Ağacan [Wed, 16 Jan 2019 06:47:35 +0000 (09:47 +0300)] 
Documentation for StgRetFun

6 months agoMake sure 'haddock' package also copies resources
Alec Theriault [Thu, 10 Jan 2019 12:37:36 +0000 (04:37 -0800)] 
Make sure 'haddock' package also copies resources

...and does so in the lib folder of the right stage

6 months agoHadrian: handle Haddock's resource directory
Alec Theriault [Thu, 10 Jan 2019 11:45:06 +0000 (03:45 -0800)] 
Hadrian: handle Haddock's resource directory

Fixes #16105

  * Require Haddock's resource as runtime dependencies of the Haddock
    builder. This means we no longer have to `need` particular resources
    in every other documentation rule.

  * Do a _tracked_ copy of both the 'html' and 'latex' folder resource
    folders.

  * Move resources into `stage1/lib` (NB: the `haddock` binary goes in
    `stage1/bin`). Besides now actually matching the Haddock script
    wrapper generated by BinaryDist, this also prepares for Haddock
    in relocatable build folder detecting its own resources.

6 months agoImprove clarity of documentation for maybeToList
Steve Hart [Thu, 10 Jan 2019 13:30:47 +0000 (08:30 -0500)] 
Improve clarity of documentation for maybeToList

6 months agoRevert "Fix typo in maybeToList documentation"
Steve Hart [Thu, 10 Jan 2019 13:29:29 +0000 (08:29 -0500)] 
Revert "Fix typo in maybeToList documentation"

This reverts commit af210f40ce7ad7b3351abc988b0351446e8b639e

6 months agoFix typo in maybeToList documentation
Steve Hart [Thu, 10 Jan 2019 03:21:38 +0000 (22:21 -0500)] 
Fix typo in maybeToList documentation

6 months agoHadrian: Use the Cabal build script on Windows by default
Andrey Mokhov [Thu, 10 Jan 2019 00:18:24 +0000 (00:18 +0000)] 
Hadrian: Use the Cabal build script on Windows by default

The Stack build script `build.stack.bat` currently fails on Windows
when invoked with the `--configure` flag, see:

https://ghc.haskell.org/trac/ghc/ticket/15982

The Cabal build script `build.cabal.bat` works reliably on my Windows
machine, so I am proposing to switch to it by default, that is, to run
it from the default `build.bat` script.

The Stack build script can still be run directly if need be.

6 months agoDisable Shake Lint by default.
Andrey Mokhov [Thu, 10 Jan 2019 22:35:22 +0000 (22:35 +0000)] 
Disable Shake Lint by default.

6 months agoSwitch to the untracked version of getDirectoryFiles when scanning for GMP objects
Andrey Mokhov [Wed, 9 Jan 2019 21:34:03 +0000 (21:34 +0000)] 
Switch to the untracked version of getDirectoryFiles when scanning for GMP objects

See https://ghc.haskell.org/trac/ghc/ticket/15971.

This is work in progress: this commit does the right thing, but does not
yet fix the ticket.

6 months agotypo
Alp Mestanogullari [Wed, 9 Jan 2019 21:40:25 +0000 (22:40 +0100)] 
typo

6 months agocrosslink hadrian/README.md and hadrian/doc/make.md
Alp Mestanogullari [Wed, 9 Jan 2019 11:51:50 +0000 (12:51 +0100)] 
crosslink hadrian/README.md and hadrian/doc/make.md

6 months agodoc: behaviour of +RTS -h depends on profiling
Ben Price [Tue, 15 Jan 2019 12:38:44 +0000 (12:38 +0000)] 
doc: behaviour of +RTS -h depends on profiling

The rts option `-h` behaves as `-hT` when compiled without profiling,
and `-hc` when compiled with profiling. Add a note to the user's guide
highlighting this inconsistency.

6 months agodoc: reorder heap profiling information in +RTS -?
Ben Price [Mon, 14 Jan 2019 18:26:45 +0000 (18:26 +0000)] 
doc: reorder heap profiling information in +RTS -?

6 months agorts: Allow heap prof by closure type in prof way
Ben Price [Tue, 8 Jan 2019 22:16:10 +0000 (22:16 +0000)] 
rts: Allow heap prof by closure type in prof way

Complete b7b6617a90824303daf555c817f538cd9c792671 (see ticket #15086) to
actually enable profiling by closure type in the profiling rts. I.e.
+RTS -p -hT is now accepted.