ghc.git
4 years agoImprove kind-checking for 'deriving' clauses
Simon Peyton Jones [Thu, 25 Jun 2015 14:48:37 +0000 (15:48 +0100)] 
Improve kind-checking for 'deriving' clauses

The main payload is in 'mk_functor_like_constraints' in
TcDeriv.inferConstraints.

This is moving towards a fix for Trac #10561

4 years agodriver: pass '-fPIC' option to all CC invocations
Sergei Trofimovich [Wed, 24 Jun 2015 21:10:47 +0000 (22:10 +0100)] 
driver: pass '-fPIC' option to all CC invocations

Reported by mitchty:

  When porting ghc to alpine linux (rumors say they build
  all binaries as Position Independent Executables
  to leverage global ASLR) linker issued obscure errors:

Tiny example:
    $ echo 'main = print "hello"' > a.hs
    $ ghc -fforce-recomp a.hs -fPIC -dynamic -optl-pie -o a
        ld: /tmp/ghc2142_0/ghc2142_5.o: relocation R_X86_64_32 against `ZCMain_main_closure'
            can not be used when making a shared object; recompile with -fPIC
        /tmp/ghc2142_0/ghc2142_5.o: error adding symbols: Bad value
        collect2: error: ld returned 1 exit status

There is two entry points in CC driver:
    'runPhase' (CC) and 'mkExtraObj'

'mkExtraObj' does not handle most of 'runPhase's complexity.
Ideally it should.

This patch only adds -fPIC propagation to 'mkExtraObj'.

Please merge to stable branch.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoClean outdated ext-core references in comments.
Sergei Trofimovich [Sun, 21 Jun 2015 20:11:22 +0000 (21:11 +0100)] 
Clean outdated ext-core references in comments.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoDrop prefix from package keys.
Edward Z. Yang [Tue, 23 Jun 2015 17:41:45 +0000 (10:41 -0700)] 
Drop prefix from package keys.

Summary:
Contains Cabal submodule update, as Cabal is responsible
generating package keys.  We also have to update some output.

Also comes with a documentation update for ghc-pkg in the
user manual for --package-key.

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

Reviewers: simonpj, austin

Subscribers: thomie, bgamari

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

GHC Trac Issues: #10550

4 years agoBuild system: delete unused variables in config.mk.in
Thomas Miedema [Tue, 23 Jun 2015 15:08:48 +0000 (17:08 +0200)] 
Build system: delete unused variables in config.mk.in

GhcStage1DefaultNewCodegen, GhcStage2DefaultNewCodegen,
GhcStage3DefaultNewCodegen and GhcCompilerWays are not used anywhere.

4 years agoMake $1 in $1_$2_$3_FOO actually be directory.
Edward Z. Yang [Sat, 20 Jun 2015 23:32:56 +0000 (16:32 -0700)] 
Make $1 in $1_$2_$3_FOO actually be directory.

Summary:
Previously, we used $1_$2_PACKAGE_KEY to parametrize $1.  But the
documentation says that $1 should be the directory...  and we're now
putting the libraries in $1_$2_LIB_NAME.  So use /that/.  This is just
alpha-renaming, so as long as we're consistent, there's no material
difference.)

I also fixed a bug of a package ID calculation which I missed first
time around, which was tickled by this change.

BTW, this means DEP_KEYS and TRANSITIVE_DEP_KEYS are unused, so
remove them from ghc-cabal.

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

Reviewers: austin

Subscribers: thomie, bgamari

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

4 years agopowerpc: add basic support for PLT relocations (#10402)
Sergei Trofimovich [Tue, 23 Jun 2015 12:39:34 +0000 (07:39 -0500)] 
powerpc: add basic support for PLT relocations (#10402)

Commit a93ab43ab5f40cadbedea2f6342b93c245e91434
enabled support for proper PIC relocations from
assembler.

Commit adds support for relocations of type:
    R_PPC_REL16_HI
    R_PPC_REL16_HA
    R_PPC_REL16_LO
    R_PPC_PLTREL24

They are used only when GHC is built in
    DYNAMIC_GHC_PROGRAMS = NO
mode.

Verified by running the following test:

    // cat a.c
    #include <stdio.h>

    void ffi_a_hello (int i) {
        fprintf (stderr, "WEEEEEEEE: i=%d\n", i);
    }

    -- cat A.hs
    {-# LANGUAGE ForeignFunctionInterface #-}
    module A where

    import Foreign.C

    foreign import ccall "ffi_a_hello" a :: CInt -> IO ()

    # ghc -fPIC -c a.c -fforce-recomp
    # ghc -fPIC -c A.hs -fforce-recomp
    # ghc --interactive ./a.o A
    ...
    *A> a 42
    WEEEEEEEE: i=42
See gory details in Trac #10402.

Signed-off-by: Colin Watson <cjwatson@debian.org>
Signed-off-by: Sergei Trofimovich <siarheit@google.com>
Reviewed By: bgamari, austin

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

GHC Trac Issues: #10402

4 years agoFurther elaborate Trac #10403 test
Simon Peyton Jones [Tue, 23 Jun 2015 12:14:26 +0000 (13:14 +0100)] 
Further elaborate Trac #10403 test

Adding app1, app2, as requested in the ticket

4 years agoRename $1_$2_$3_LIB_NAME to LIB_FILE.
Edward Z. Yang [Sat, 20 Jun 2015 23:23:58 +0000 (16:23 -0700)] 
Rename $1_$2_$3_LIB_NAME to LIB_FILE.

Summary:
When we introduced user-friendly library names
(e.g. unix-2.7.1.0-G4Yo1pNtYrk8nCq1cx8P9d instead of
unix_G4Yo1pNtYrk8nCq1cx8P9d) we added a new variable to
be written out by ghc-cabal, $1_$2_LIB_NAME.

What I didn't realize at the time was that this conflicts
with an existing variable in the build system, $1_$2_$3_LIB_NAME,
which (confusingly) refers to something like
'libHSunix-2.7.1.0-G4Yo1pNtYrk8nCq1cx8P9d.so'.  This is pretty
confusing (despite never conflicting), so I renamed this variable
to LIB_FILE for enhanced greppability.

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

Reviewers: austin

Subscribers: thomie, bgamari

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

4 years agoFix #10551 by using LIB_NAMES.
Edward Z. Yang [Sat, 20 Jun 2015 23:15:41 +0000 (16:15 -0700)] 
Fix #10551 by using LIB_NAMES.

Summary:
(NB: this code is dead at the moment since Windows is not built
dynamically.)

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

Reviewers: austin

Subscribers: thomie, bgamari

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

GHC Trac Issues: #10551

4 years agoUse -package-id to specify libraries on command line.
Edward Z. Yang [Sat, 20 Jun 2015 22:35:28 +0000 (15:35 -0700)] 
Use -package-id to specify libraries on command line.

Summary:
There's not really any good reason to use -package-key over
-package-id, so use the latter as standard practice.

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

Reviewers: austin

Subscribers: thomie, bgamari

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

4 years agoCheck KnownSymbol => Typeable deduction
Gabor Greif [Mon, 22 Jun 2015 13:40:01 +0000 (15:40 +0200)] 
Check KnownSymbol => Typeable deduction

verifying fix for #10348

4 years agoDocumentation: add section on .haskeline file (#2531)
Thomas Miedema [Sun, 21 Jun 2015 18:56:56 +0000 (20:56 +0200)] 
Documentation: add section on .haskeline file (#2531)

4 years agoAdd parsePattern parser entry point
Alan Zimmerman [Sun, 21 Jun 2015 19:52:58 +0000 (21:52 +0200)] 
Add parsePattern parser entry point

Reviewers: austin, thomie, alanz

Reviewed By: thomie, alanz

Subscribers: thomie, bgamari

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

GHC Trac Issues: #10556

4 years agoChange `Typeable` instance for type-lis to use the Known* classes.
Iavor S. Diatchki [Sun, 21 Jun 2015 19:24:42 +0000 (12:24 -0700)] 
Change `Typeable` instance for type-lis to use the Known* classes.

This should fix T10348

4 years agoBuild system: unset HADDOCK when haddock is not found
Thomas Miedema [Thu, 18 Jun 2015 17:40:40 +0000 (19:40 +0200)] 
Build system: unset HADDOCK when haddock is not found

This prevents the following test errors on Windows:

   perf/haddock haddock.Cabal [[Errno 2] No such file or directory: ...
   perf/haddock haddock.base [[Errno 2] No such file or directory: ...
   perf/haddock haddock.compiler [[Errno 2] No such file or directory: ...

The tests will now be reported as having missing libraries.

4 years agoRemove duplicate test.
Edward Z. Yang [Sat, 20 Jun 2015 23:12:20 +0000 (16:12 -0700)] 
Remove duplicate test.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agoFix all.T for T8131/T8131b.
Edward Z. Yang [Sat, 20 Jun 2015 22:58:46 +0000 (15:58 -0700)] 
Fix all.T for T8131/T8131b.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agoFilter orphan rules based on imports, fixes #10294 and #10420.
Edward Z. Yang [Wed, 3 Jun 2015 21:33:05 +0000 (14:33 -0700)] 
Filter orphan rules based on imports, fixes #10294 and #10420.

Summary:
If we have an orphan rule in our database, don't apply it
unless the defining module is transitively imported by the
module we are processing.  We do this by defining a new RuleEnv
data type which includes both the RuleBase as well as the set
of visible orphan modules, and threading this through the
relevant environments (CoreReader, RuleCheckEnv and ScEnv).

This is analogous to the instances fix we applied in #2182
4c834fdddf4d44d12039da4d6a2c63a660975b95, but done for RULES.
An important knock-on effect is that we can remove some buggy
code in LoadInterface which tried to avoid loading interfaces
that were loaded by plugins (which sometimes caused instances
and rules to NEVER become visible).

One note about tests: I renamed the old plugins07 test to T10420
and replaced plugins07 with a test to ensure that a plugin
import did not cause new rules to be loaded in.

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

Reviewers: simonpj, austin, goldfire

Subscribers: bgamari, thomie

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

GHC Trac Issues: #10420

4 years agoMake GHC install libraries to e.g. xhtml-3000.2.1-0ACfOp3hebWD9jGWE4v4Gh.
Edward Z. Yang [Fri, 29 May 2015 00:11:12 +0000 (17:11 -0700)] 
Make GHC install libraries to e.g. xhtml-3000.2.1-0ACfOp3hebWD9jGWE4v4Gh.

Summary:
Previously, we'd install them to something like
xhtml_0ACfOp3hebWD9jGWE4v4G which was fairly ugly; this
commit changes the default install path to contain the full
package name and version, as well as the package key.

Needs a Cabal submodule update for the commit for install paths support
"Add libname install-dirs variable, use it by default. Fixes #2437".
It also contains some miscellaneous fixes for Cabal HEAD.

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

Reviewers: austin

Subscribers: bgamari, thomie

Trac Issues: #10479

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

4 years agoUpdated output for test ghci024
Sergei Trofimovich [Sat, 20 Jun 2015 11:47:50 +0000 (12:47 +0100)] 
Updated output for test ghci024

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoRecognise 'hardhloat' as a valid vendor in a host tuple
Sergei Trofimovich [Sat, 20 Jun 2015 11:23:00 +0000 (12:23 +0100)] 
Recognise 'hardhloat' as a valid vendor in a host tuple

Observed on a tuple armv7a-hardfloat-linux-gnueabi:
> Unknown vendor hardfloat

Reported-by: Sergey Alirzaev
Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoFix a couple of tests for GHCi/-O* (Trac #10052)
Sergei Trofimovich [Sat, 20 Jun 2015 09:24:40 +0000 (10:24 +0100)] 
Fix a couple of tests for GHCi/-O* (Trac #10052)

Tests use unboxed types (or optimizer gets to them),
those can't be handled by ghci. Fixed by using -fobject-code.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoAmend tcrun037 after Trac #7854 fix
Sergei Trofimovich [Sat, 20 Jun 2015 09:04:28 +0000 (10:04 +0100)] 
Amend tcrun037 after Trac #7854 fix

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoAmend tcrun024, tcrun025 after Trac #7854 fix
Sergei Trofimovich [Sat, 20 Jun 2015 08:51:36 +0000 (09:51 +0100)] 
Amend tcrun024, tcrun025 after Trac #7854 fix

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoshould_run/allocLimit4: disable ghci way
Sergei Trofimovich [Fri, 19 Jun 2015 21:54:15 +0000 (22:54 +0100)] 
should_run/allocLimit4: disable ghci way

Test sets allocation limit for a current main thread,
ghci already loaded a bunch of stuff in it.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agodocs: Unbreak the PS/PDF builds for the User's Guide (#10509)
Gabor Pali [Fri, 19 Jun 2015 21:19:30 +0000 (23:19 +0200)] 
docs: Unbreak the PS/PDF builds for the User's Guide (#10509)

dblatex can only translate the Unicode glyphs introduced in #10509 for LaTeX
if the `latex.unicode.use=1` flag is set, otherwise it will just fail.
However, note that adding this flag is not going to fully solve the problem as
those symbols are not known by LaTeX, so the corresponding character codes
will be added instead to the resulting PS/PDF files.  Hence it is considered
an interim solution only, not a true fix, until a better one is found.

4 years agotestsuite: mark T4945 as expect_broken
Austin Seipp [Fri, 19 Jun 2015 17:28:14 +0000 (12:28 -0500)] 
testsuite: mark T4945 as expect_broken

This was working, and then it started failing again; it's a pretty
fragile test anyway because it 'grep's the output of the compiler.

In the mean time, make the CI system quiet down by marking it
appropriately.

Signed-off-by: Austin Seipp <austin@well-typed.com>
4 years agoSpelling in comments
Gabor Greif [Tue, 16 Jun 2015 11:14:38 +0000 (13:14 +0200)] 
Spelling in comments

4 years agoElaborate test for Trac #10403
Simon Peyton Jones [Thu, 18 Jun 2015 22:26:48 +0000 (23:26 +0100)] 
Elaborate test for Trac #10403

4 years agoTest Trac #10503
Simon Peyton Jones [Thu, 18 Jun 2015 14:45:22 +0000 (15:45 +0100)] 
Test Trac #10503

4 years agoParser: commas_tup_tail duplicate SrcSpan on "Missing" value
Alan Zimmerman [Thu, 18 Jun 2015 14:19:50 +0000 (16:19 +0200)] 
Parser: commas_tup_tail duplicate SrcSpan on "Missing" value

Summary:
Parsing

    {-# LANGUAGE TupleSections #-}

    baz = (1, "hello", 6.5,,) 'a' (Just ())

Results in the following AST fragment

    (L tests/examples/Tuple.hs:3:7-25
       (ExplicitTuple
          [ L tests/examples/Tuple.hs:3:8
              (Present
                 (L tests/examples/Tuple.hs:3:8
                    (HsOverLit
                       (OverLit
                          (HsIntegral [ '1' ] 1)
                          PlaceHolder
                          (HsLit
                             (HsString
                                []
                                {abstract:FastString}))
                          PlaceHolder))))
          , L tests/examples/Tuple.hs:3:11-17
              (Present
                 (L tests/examples/Tuple.hs:3:11-17
                    (HsLit
                       (HsString
                          [ '"'
                          , 'h'
                          , 'e'
                          , 'l'
                          , 'l'
                          , 'o'
                          , '"'
                          ]
                          {abstract:FastString}))))
          , L tests/examples/Tuple.hs:3:20-22
              (Present
                 (L tests/examples/Tuple.hs:3:20-22
                    (HsOverLit
                       (OverLit
                          (HsFractional
                             (FL
                                [ '6' , '.' , '5' ]
                                (:% 13 2)))
                          PlaceHolder
                          (HsLit
                             (HsString
                                []
                                {abstract:FastString}))
                          PlaceHolder))))
          , L tests/examples/Tuple.hs:3:24
              (Missing PlaceHolder)
          , L tests/examples/Tuple.hs:3:24
              (Missing PlaceHolder)
          ]

The final `Missing PlaceHolder` has a duplicated `SrcSpan`

Test Plan: ./validate

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: thomie, bgamari, mpickering

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

GHC Trac Issues: #10537

4 years agoTrac #4945 is working again
Simon Peyton Jones [Thu, 18 Jun 2015 14:18:19 +0000 (15:18 +0100)] 
Trac #4945 is working again

This test greps in the ouput of -ddump-simpl, so it's fragile.
It stopped working for a while, but now works again. I don't know
why, but I don't have time to investigate, so I'll just mark it
as ok.

4 years agoRefactor filterAlts into two parts
Simon Peyton Jones [Thu, 18 Jun 2015 14:16:59 +0000 (15:16 +0100)] 
Refactor filterAlts into two parts

This splits filterAlts into two:
 - filterAlts
 - refineDefaultAlt

No change in functionality

4 years agoComments plus tiny refactoring
Simon Peyton Jones [Thu, 18 Jun 2015 13:14:01 +0000 (14:14 +0100)] 
Comments plus tiny refactoring

4 years agoA bit more tracing
Simon Peyton Jones [Thu, 18 Jun 2015 13:13:24 +0000 (14:13 +0100)] 
A bit more tracing

4 years agoRemove some horrible munging of origins for Coercible
Simon Peyton Jones [Thu, 18 Jun 2015 13:12:54 +0000 (14:12 +0100)] 
Remove some horrible munging of origins for Coercible

I just didn't think it was buying enough for all the cruft it caused.
We can put some back if people start complaining about poor error
messages. I forget quite how I tripped over this but I got sucked in.

* Lots of tidying up in TcErrors

* Rename pprArisingAt to pprCtLoc, by analogy with pprCtOrigin

* Remove CoercibleOrigin data constructor from CtOrigin

* Make relevantBindings return a Ct with a zonked
  and tidied CtOrigin

* Add to TcRnTypes
      ctOrigin   :: Ct -> CtOrigin
      ctEvOrigin :: CtEvidence -> CtOrigin
      setCtLoc   :: Ct -> CtLoc -> Ct

4 years agoRename getCtLoc, setCtLoc
Simon Peyton Jones [Thu, 18 Jun 2015 12:55:41 +0000 (13:55 +0100)] 
Rename getCtLoc, setCtLoc

getCtLoc -> getCtLocM
setCtLoc -> setCtLocM

These operations are monadic, and I want to introduce a
pure version of setCtLoc :: Ct -> CtLoc -> Ct

4 years agoComments only
Simon Peyton Jones [Wed, 17 Jun 2015 11:31:26 +0000 (12:31 +0100)] 
Comments only

Rewording in
  Note [Decomposing equality]
  Note [Decomposing newtypes at representational role]

Richard you may want to check, but I think it's fine.

4 years agoReport arity errors correctly despite kinds
Simon Peyton Jones [Thu, 18 Jun 2015 07:54:11 +0000 (08:54 +0100)] 
Report arity errors correctly despite kinds

Trac #10516 pointed out that when reporting arity errors
(like "T needs 2 arguments but has been given 1"), we should
not count kind arguments, since they are implicit.  If we
include kind args in the count, we get very confusing error
messages indeed.

I did a little bit of refactoring which make some
error messages wobble around.  But the payload of
this fix is in TcValidity.tyConArityErr

4 years agoCare with impossible-cons in combineIdenticalAlts
Simon Peyton Jones [Thu, 18 Jun 2015 07:51:08 +0000 (08:51 +0100)] 
Care with impossible-cons in combineIdenticalAlts

This was a nasty, long-standing bug exposed in Trac #10538.
Symptoms were that we had an empty case
   case (x :: Either a) of {}
Core Lint correctly picked this bogus code up.

Here is what happened

* In SimplUtils.prepareAlts, we call
        filterAlts
  then
        combineIdenticalAlts

* We had    case x of { Left _ -> e1; Right _ -> e1 }

* filterAlts did nothing, but correctly retuned imposs_deflt_cons
  saying that 'x' cannot be {Left, Right} in the DEFAULT branch,
  if any (there isn't one.)

* combineIdentialAlts correctly combines the identical alts, to give
     case x of { DEFAULT -> e1 }

* BUT combineIdenticalAlts did no adjust imposs_deft_cons

* Result: when compiling e1 we did so in the belief that 'x'
  could not be {Left,Right}.  Disaster.

Easily fixed.

(It is hard to trigger; I can't construct a simple test case.)

4 years agoMake enum01/enum02/enum03 tests clang-compatible
Reid Barton [Tue, 16 Jun 2015 21:39:15 +0000 (16:39 -0500)] 
Make enum01/enum02/enum03 tests clang-compatible

... by entirely replacing the use of CPP by a custom preprocessor;
clang -E -traditional has no stringification mechanism at all.

Reviewed By: thomie, austin

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

GHC Trac Issues: #9399

4 years agoUpdate foreign export docs, fixes #10467
Edward Z. Yang [Tue, 16 Jun 2015 21:38:59 +0000 (16:38 -0500)] 
Update foreign export docs, fixes #10467

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Reviewed By: rwbarton, austin

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

GHC Trac Issues: #10467

4 years agoFix ghc-pkg reports cache out date (#10205)
Thomas Miedema [Tue, 16 Jun 2015 21:38:38 +0000 (16:38 -0500)] 
Fix ghc-pkg reports cache out date (#10205)

See Note [writeAtomic leaky abstraction].

GHC on Linux already received a patch for this bug in
e0801a0fb342eea9a312906eab72874d631271cf. On Windows several cabal tests
were hitting the bug, causing validate failures, but we never noticed
because of all the other tests that were failing on Windows. And it
didn't start happening till `getModificationTime` received sub-second
resolution support on Windows in
5cf76186d373842bf64d49cecb09e0a9ddce3203.

Since there are regression tests already, I am not adding another one.
But for good measure, here is a script that shows the bug without
needing to do a full validate run:

  DB=/tmp/package.conf.d.test
  GHC_PKG=ghc-pkg #utils/ghc-pkg/dist/build/tmp/ghc-pkg
  LOCAL_GHC_PKG="${GHC_PKG} --no-user-package-db --global-package-db=${DB}"
  while true; do
    rm -rf ${DB}
    ${LOCAL_GHC_PKG} init "${DB}"
    ${LOCAL_GHC_PKG} list
  done

If you see "WARNING: cache is out of date" after a few seconds, the bug
is not fixed.

Reviewed By: austin

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

GHC Trac Issues: #10205

4 years agoAdd `Monoid` instance for `IO`
Gabriel Gonzalez [Tue, 16 Jun 2015 21:38:18 +0000 (16:38 -0500)] 
Add `Monoid` instance for `IO`

See original proposal at
https://mail.haskell.org/pipermail/libraries/2014-November/024310.html
for more details

Reviewed By: hvr, austin

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

GHC Trac Issues: #10523

4 years agoClarify some comments around injectivity.
Richard Eisenberg [Tue, 16 Jun 2015 12:45:04 +0000 (08:45 -0400)] 
Clarify some comments around injectivity.

4 years agoFix typo in comment
Richard Eisenberg [Tue, 16 Jun 2015 01:01:26 +0000 (21:01 -0400)] 
Fix typo in comment

4 years agoTreat funTyCon like any other TyCon in can_eq_nc.
Richard Eisenberg [Tue, 16 Jun 2015 00:49:10 +0000 (20:49 -0400)] 
Treat funTyCon like any other TyCon in can_eq_nc.

Custom treatment of FunTys in can_eq_nc' interfered with the new
handling of decomposing equalities.

4 years agoReimplement Unify.typesCantMatch in terms of apartness.
Richard Eisenberg [Tue, 16 Jun 2015 12:57:52 +0000 (08:57 -0400)] 
Reimplement Unify.typesCantMatch in terms of apartness.

Because typesCantMatch must also work with type functions, this
requires teaching the unifier about type functions and injectivity.
Also, some refactoring to use the UM monad more.

4 years agoRefactor handling of decomposition.
Richard Eisenberg [Mon, 15 Jun 2015 21:02:36 +0000 (17:02 -0400)] 
Refactor handling of decomposition.

This adds the significant Note [Decomposing equalities] to
TcCanonical, trying to sort out the various cases involved.

The only functional change this commit should make is a different
treatment of data families, which were wrong before (they could
be decomposed at role R, which is wrong).

4 years agoTestsuite wibble around decomposing newtypes.
Richard Eisenberg [Tue, 9 Jun 2015 20:52:40 +0000 (16:52 -0400)] 
Testsuite wibble around decomposing newtypes.

This is actually an improvement. Yay!

4 years ago(mostly) Comments only
Richard Eisenberg [Tue, 9 Jun 2015 16:14:10 +0000 (12:14 -0400)] 
(mostly) Comments only

The one non-comment change is a small refactoring/simplification
in TcCanonical that should have no impact: avoiding flattening twice.

4 years agoDecompose wanted repr. eqs. when no matchable givens.
Richard Eisenberg [Tue, 9 Jun 2015 02:32:40 +0000 (22:32 -0400)] 
Decompose wanted repr. eqs. when no matchable givens.

This is pursuant to a conversion with SPJ, where we agreed that
the logic behind Note [Instance and Given overlap] in TcInteract
applied to newtype decomposition for representational equality.

There is no bug report or test case, as tickling this kind of thing
is quite hard to do!

4 years agoTest case for #10428.
Richard Eisenberg [Mon, 8 Jun 2015 20:52:59 +0000 (16:52 -0400)] 
Test case for #10428.

4 years agoFix #10493.
Richard Eisenberg [Mon, 8 Jun 2015 20:46:46 +0000 (16:46 -0400)] 
Fix #10493.

Now, a Coercible (T1 ...) (T2 ...) constraint is insoluble only
when both T1 and T2 say "yes" to isDistinctTyCon. Several comments
also updated in this patch.

4 years agoFix #10495.
Richard Eisenberg [Mon, 8 Jun 2015 19:57:33 +0000 (15:57 -0400)] 
Fix #10495.

This change means that the intricate reasoning in TcErrors
around getting messages just right for nominal equalities
is skipped for representational equalities.

4 years agoFix #10494
Richard Eisenberg [Fri, 5 Jun 2015 20:54:21 +0000 (16:54 -0400)] 
Fix #10494

Now representational AppTys are just IrredEvCans, as they should be.

Test case: typecheck/should_compile/T10494

4 years agoEncode alignment in MO_Memcpy and friends
Ben Gamari [Tue, 16 Jun 2015 18:16:16 +0000 (20:16 +0200)] 
Encode alignment in MO_Memcpy and friends

Summary:
Alignment needs to be a compile-time constant. Previously the code
generators had to jump through hoops to ensure this was the case as the
alignment was passed as a CmmExpr in the arguments list. Now we take
care of this up front.

This fixes #8131.

Authored-by: Reid Barton <rwbarton@gmail.com>
Dusted-off-by: Ben Gamari <ben@smart-cactus.org>
Tests for T8131

Test Plan: Validate

Reviewers: rwbarton, austin

Reviewed By: rwbarton, austin

Subscribers: bgamari, carter, thomie

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

GHC Trac Issues: #8131

4 years agoEncode alignment in MO_Memcpy and friends
Ben Gamari [Tue, 16 Jun 2015 18:16:08 +0000 (20:16 +0200)] 
Encode alignment in MO_Memcpy and friends

Summary:
Alignment needs to be a compile-time constant. Previously the code
generators had to jump through hoops to ensure this was the case as the
alignment was passed as a CmmExpr in the arguments list. Now we take
care of this up front.

This fixes #8131.

Authored-by: Reid Barton <rwbarton@gmail.com>
Dusted-off-by: Ben Gamari <ben@smart-cactus.org>
Tests for T8131

Test Plan: Validate

Reviewers: rwbarton, austin

Reviewed By: rwbarton, austin

Subscribers: bgamari, carter, thomie

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

GHC Trac Issues: #8131

4 years agousers_guide: Various spelling fixes
Ben Gamari [Tue, 16 Jun 2015 18:06:00 +0000 (20:06 +0200)] 
users_guide: Various spelling fixes

Summary:
Today when reading through the users manual I noticed a few spelling issues.
This prompted me to run the document through ispell which turned up even more
issues. I've tried to be conservative here; most of the corrections are
misspellings and typos but in a few cases I've moved from American to British
orthography.

Test Plan: Read.

Reviewers: austin

Reviewed By: austin

Subscribers: bgamari, thomie

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

4 years agousers_guide: Various spelling fixes
Ben Gamari [Tue, 16 Jun 2015 18:05:43 +0000 (20:05 +0200)] 
users_guide: Various spelling fixes

Summary:
Today when reading through the users manual I noticed a few spelling issues.
This prompted me to run the document through ispell which turned up even more
issues. I've tried to be conservative here; most of the corrections are
misspellings and typos but in a few cases I've moved from American to British
orthography.

Test Plan: Read.

Reviewers: austin

Reviewed By: austin

Subscribers: bgamari, thomie

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

4 years agoLexer: Suggest adding 'let' on unexpected '=' token
Ben Gamari [Tue, 16 Jun 2015 18:04:02 +0000 (20:04 +0200)] 
Lexer: Suggest adding 'let' on unexpected '=' token

Summary:
I've heard numerous fledgling Haskeller's complain about the behavior of
ghci regarding bindings. While most REPLs accept bindings of the form
`x = 42`, GHCi is implicitly a `do` block, meaning that the user must
know to use a `let` to introduce a binding.

Here we suggest to the user that they may need a `let` and give them a
small example in the event that we find an unexpected `=` token.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, bgamari

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

4 years agoLexer: Suggest adding 'let' on unexpected '=' token
Ben Gamari [Tue, 16 Jun 2015 18:01:22 +0000 (20:01 +0200)] 
Lexer: Suggest adding 'let' on unexpected '=' token

Summary:
I've heard numerous fledgling Haskeller's complain about the behavior of
ghci regarding bindings. While most REPLs accept bindings of the form
`x = 42`, GHCi is implicitly a `do` block, meaning that the user must
know to use a `let` to introduce a binding.

Here we suggest to the user that they may need a `let` and give them a
small example in the event that we find an unexpected `=` token.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, bgamari

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

4 years agoghc.mk: Update instances of -auto-all
Ben Gamari [Tue, 16 Jun 2015 17:53:14 +0000 (19:53 +0200)] 
ghc.mk: Update instances of -auto-all

-auto-all is now -fprof-auto.

Reviewed By: austin

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

4 years agoFix #10534
Richard Eisenberg [Tue, 16 Jun 2015 01:55:52 +0000 (21:55 -0400)] 
Fix #10534

Test case: typecheck/should_fail/T10534

4 years agoTestsuite: fix framework failure
Thomas Miedema [Mon, 15 Jun 2015 14:19:42 +0000 (16:19 +0200)] 
Testsuite: fix framework failure

I forgot to rename this in 5ddd90415f307cac72d75d86da58e552b168ee30.

4 years agoImproved peak_megabytes_allocated
Simon Peyton Jones [Mon, 15 Jun 2015 13:23:32 +0000 (14:23 +0100)] 
Improved peak_megabytes_allocated

I have no idea why, but lower is good

4 years agoSpelling in comments
Simon Peyton Jones [Mon, 15 Jun 2015 12:33:36 +0000 (13:33 +0100)] 
Spelling in comments

4 years agoGHCi: fix scoping for record selectors
Simon Peyton Jones [Mon, 15 Jun 2015 12:32:48 +0000 (13:32 +0100)] 
GHCi: fix scoping for record selectors

This fixes Trac #10520.  See the "Ugh" note about
record selectors in HscTypes.icExtendGblRdrEnv.

4 years agoRemove derived CFunEqCans after solving givens
Simon Peyton Jones [Mon, 15 Jun 2015 12:23:16 +0000 (13:23 +0100)] 
Remove derived CFunEqCans after solving givens

See Note [The inert set after solving Givens] in TcSMonad.

This fixes Trac #10507.

4 years agoDemonstrate that inferring Typeable for type literals works
Gabor Greif [Mon, 15 Jun 2015 11:30:24 +0000 (13:30 +0200)] 
Demonstrate that inferring Typeable for type literals works

So #10348 is only missing the variable case:
  Known{Nat,Symbol} lit => Typeable lit

4 years agoTest Trac #10348
Gabor Greif [Mon, 15 Jun 2015 09:00:45 +0000 (11:00 +0200)] 
Test Trac #10348

4 years agoIncrease constraint tuple limit to 62 (Trac #10451)
Nick Terrell [Mon, 15 Jun 2015 01:32:22 +0000 (20:32 -0500)] 
Increase constraint tuple limit to 62 (Trac #10451)

  * Increase max constraint tuple size to 62
  * Modify test case to reflect change

Reviewed By: austin

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

GHC Trac Issues: #10451

4 years agoadd type annotations to SrcLoc functions
Ömer Sinan Ağacan [Mon, 15 Jun 2015 01:30:29 +0000 (20:30 -0500)] 
add type annotations to SrcLoc functions

Because sometimes types make more sense than docs.

Reviewed By: austin

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

4 years agoUNREG: fix pprHexVal to emit zeros (#10518)
Sergei Trofimovich [Sun, 14 Jun 2015 15:42:03 +0000 (16:42 +0100)] 
UNREG: fix pprHexVal to emit zeros (#10518)

jakzale on #ghc reported a build failure
when ported GHC on a new target.

The code 'pprHexVal (2^32) W32' emits '0xU'
which is invalid C.

I've introduced bug in
    43f1b2ecd1960fa7377cf55a2b97c66059a701ef
when added literal truncation. That truncation
is a new source of zeros.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
Test Plan: added test and tested on UNREG ghc

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, bgamari

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

GHC Trac Issues: #10518

4 years agoTestsuite: add function compile_timeout_multiplier (#10345)
Thomas Miedema [Fri, 12 Jun 2015 11:52:02 +0000 (13:52 +0200)] 
Testsuite: add function compile_timeout_multiplier (#10345)

And rename timeout_multiplier to run_timeout_multiplier.

timeout_multiplier was added in commit
a00389794b839971c7d52ead9e8570bfaa25ac55. The name suggested that it
would affect any test, but it actually only affected tests that had a
run component, and only that run component (as needed by test T367).

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

4 years agoTestsuite: diff non-whitespace normalised output (#10152)
Thomas Miedema [Fri, 12 Jun 2015 14:29:18 +0000 (16:29 +0200)] 
Testsuite: diff non-whitespace normalised output (#10152)

On a test failure, we show a diff between the expected and the actual
output. The method of how we do this has changed a couple of times:

* In 2007: 9951189ccf90b709436fa55ee49eeef031f79f4e
  "On failure, diff the normalised test outputs"

* In 2011: 3019b1e409c129ef7af63e6a7408fb36ec44444b
  "When the output files differ, present the diffs between the *actual*
  output, not the normalised output. The latter may have newlines
  removed, making the diff unreadable."

* In 2015 (now): do something in between.
  - Do apply the normalisers again, to make the diff smaller (only
    showing the actual problem).
  - But don't apply normalise_whitespace, as it indeed makes the diff
    unreadable.

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

4 years agoAdd versioning section to Backpack docs.
Edward Z. Yang [Fri, 12 Jun 2015 19:11:41 +0000 (12:11 -0700)] 
Add versioning section to Backpack docs.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agoDocs: `-XTypeOperators` (#10175)
Thomas Miedema [Fri, 12 Jun 2015 18:06:31 +0000 (20:06 +0200)] 
Docs: `-XTypeOperators` (#10175)

[skip ci]

4 years agoDocs: it's `gv --orientation=seascape` nowadays (#10497)
Thomas Miedema [Fri, 12 Jun 2015 17:38:03 +0000 (19:38 +0200)] 
Docs: it's `gv --orientation=seascape` nowadays (#10497)

[skip ci]

4 years agoFix typo in `traceShowM` haddock comment (#10392)
Thomas Miedema [Fri, 12 Jun 2015 17:30:36 +0000 (19:30 +0200)] 
Fix typo in `traceShowM` haddock comment (#10392)

[skip ci]

4 years agoDo not copy stack after stack overflow, refix #8435
Flaviu Andrei Csernik (archblob) [Fri, 12 Jun 2015 16:45:55 +0000 (11:45 -0500)] 
Do not copy stack after stack overflow, refix #8435

Summary:
This was reverted in d70b19bfb5ed79b22c2ac31e22f46782fc47a117
and is a part of the reason for #10445.

Test Plan: validate

Reviewers: ezyang, simonmar, austin

Reviewed By: simonmar, austin

Subscribers: bgamari, thomie

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

GHC Trac Issues: #8435

4 years agoAdd parseExpr and compileParsedExpr and use them in GHC API and GHCi
Simon Marlow [Fri, 12 Jun 2015 12:15:18 +0000 (13:15 +0100)] 
Add parseExpr and compileParsedExpr and use them in GHC API and GHCi

Summary:
This commit brings following changes and fixes:

 * Implement parseExpr and compileParsedExpr;
 * Fix compileExpr and dynCompilerExpr, which returned `()` for empty expr;
 * Fix :def and :cmd, which didn't work if `IO` or `String` is not in scope;
 * Use GHCiMonad instead IO in :def and :cmd;
 * Clean PrelInfo: delete dead comment and duplicate entries, add assertion.

See new tests for more details.

Test Plan: ./validate

Reviewers: austin, dterei, simonmar

Reviewed By: simonmar

Subscribers: thomie, bgamari

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

GHC Trac Issues: #10508

4 years agoTestsuite: fix the little known CHECK_FILES_WRITTEN=1
Thomas Miedema [Sat, 30 May 2015 10:33:20 +0000 (12:33 +0200)] 
Testsuite: fix the little known CHECK_FILES_WRITTEN=1

The testsuite driver has a little known feature to check which files
each test writes to, whether there are tests that write to same file,
and whether the tests leave any files behind when CLEANUP=1. It uses
strace under the hood.

This commit fixes some bitrot, and filters out some more strace lines
that we're not interested in (and are shown as framework failures
otherwise).

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

4 years agoSquash typos in comments
Gabor Greif [Mon, 8 Jun 2015 15:15:09 +0000 (17:15 +0200)] 
Squash typos in comments

4 years agodocs: Fix unicode alternatives table (fixes #10509).
Sebastian Reuße [Fri, 12 Jun 2015 08:36:15 +0000 (10:36 +0200)] 
docs: Fix unicode alternatives table (fixes #10509).

The alternatives table gave the wrong glyphs for LEFTWARDS resp.
RIGHTWARDS ARROW-TAIL notation. The listed codepoint was correct,
but the entities corresponded to characters different from those
codepoints.

This also adds the glyphs for LEFTWARDS resp. RIGHTWARDS
DOUBLE ARROW-TAIL, which were formerly missing, and the PROPORTION
glyph, which was formerly given as ASCII.

4 years agoDelete _MSC_VER when not necessary, fix #10511
Bernard Desmyter [Fri, 12 Jun 2015 09:01:45 +0000 (11:01 +0200)] 
Delete _MSC_VER when not necessary, fix #10511

Simplify some preprocessor expressions involving `_MSC_VER` because
`_WIN32` is always defined when `_MSC_VER` is.

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

4 years agoRevert "Change loadSrcInterface to return a list of ModIface"
Edward Z. Yang [Thu, 11 Jun 2015 22:33:59 +0000 (15:33 -0700)] 
Revert "Change loadSrcInterface to return a list of ModIface"

As it turns out, in our new design these changes are no longer
needed. The code is simpler without returning a list of ModIface,
so let's do it!

This reverts commit 8c7d20d8c7e63a1123755aae69cfa825c749e9e8.

4 years agoRevert "Support for multiple signature files in scope."
Edward Z. Yang [Thu, 11 Jun 2015 22:24:27 +0000 (15:24 -0700)] 
Revert "Support for multiple signature files in scope."

This reverts commit a7524eaed33324e2155c47d4a705bef1d70a2b5b.

4 years agoRemove redundant tcg_visible_orphan_mods, it is recorded in imp_orphs.
Edward Z. Yang [Wed, 3 Jun 2015 22:29:00 +0000 (15:29 -0700)] 
Remove redundant tcg_visible_orphan_mods, it is recorded in imp_orphs.

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

Reviewers: simonpj, austin

Subscribers: bgamari, thomie

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

4 years agoAdd failing test for #9562.
Edward Z. Yang [Thu, 11 Jun 2015 21:57:50 +0000 (14:57 -0700)] 
Add failing test for #9562.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
4 years agoRemoves all occurrences of __MINGW32__ (#10485)
Thomas Miedema [Thu, 11 Jun 2015 18:31:24 +0000 (20:31 +0200)] 
Removes all occurrences of __MINGW32__ (#10485)

In Haskell files, replace `__MINGW32__` by `mingw32_HOST_OS`.

In .c and .h files, delete `__MINGW32__` when `_WIN32` is also tested
because `_WIN32` is always defined when `__MINGW32__` is. Also replace
`__MINGW32__` by `_WIN32` when used standalone for consistency.

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

4 years agoTravis: use apt-get -q
Thomas Miedema [Fri, 5 Jun 2015 10:53:51 +0000 (12:53 +0200)] 
Travis: use apt-get -q

[skip ci]

4 years agoTestsuite: change some expect_fail tests to expect_broken
Thomas Miedema [Wed, 3 Jun 2015 13:15:57 +0000 (15:15 +0200)] 
Testsuite: change some expect_fail tests to expect_broken

Change the following tests from expect_fail to expect_broken: and list
the ticket number:

    * driver/sigof03m/sigof03 (#9252)
    * driver/static001 (#8127)
    * partial-sigs/should_compile/EqualityConstraint (#9478)
    * partial-sigs/should_compile/ExtraNumAMROn (#9478)
    * partial-sigs/should_compile/PatBind2 (#9478)
    * partial-sigs/should_fail/TidyClash2 (#9478)
    * simplCore/should_compile/T8832 (#8832)

The following tests are still marked as expect_fail, but it is not
clearly documented why so:

    * gadt/lazypatok
    * indexed-types/should_fail/SkolemOccursLoop

All other expect_fail tests are only expected to fail on either a
certain platform/os or for a certain way only.

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

4 years agoTestsuite: mention the existence of ticket #10510
Thomas Miedema [Thu, 11 Jun 2015 11:46:41 +0000 (13:46 +0200)] 
Testsuite: mention the existence of ticket #10510

[skip ci]

4 years agoTestsuite: mark T4945 as expect_broken (#4945)
Thomas Miedema [Thu, 11 Jun 2015 15:25:47 +0000 (17:25 +0200)] 
Testsuite: mark T4945 as expect_broken (#4945)

In commit 7d519dabd2006c9742e82fce02df55704da15482, the file
T4945.stdout was added to the repository, to make T4945 pass
validatation presumably.

When that test produces output however, there is a bug somewhere, and we
shouldn't hide it. There is a comment in the Makefile which says:

    "When SpecConstr works there are no STUArrays at all"

So here we remove T4945.stdout again, mark T4945 as expect_broken, and
reopen the ticket.

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

4 years agoTestsuite: mark tests as expect_broken on win64
Thomas Miedema [Thu, 11 Jun 2015 17:28:03 +0000 (19:28 +0200)] 
Testsuite: mark tests as expect_broken on win64

Tickets: #1407, #9381, #9878.

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

4 years agoTestsuite Windows: fix T8172 (#8172)
Thomas Miedema [Thu, 11 Jun 2015 17:26:11 +0000 (19:26 +0200)] 
Testsuite Windows: fix T8172 (#8172)

Use the new function `normalise_drive_letter` to change D:\ to C:\
before comparing outputs.

4 years agoUpdate submodule process to master
Thomas Miedema [Thu, 11 Jun 2015 17:24:25 +0000 (19:24 +0200)] 
Update submodule process to master

This allows a warning free build on Windows, and thus an error free
validate.

4 years agoFix DWARF generation for MinGW (#10468)
Peter Wortmann [Thu, 11 Jun 2015 17:09:55 +0000 (12:09 -0500)] 
Fix DWARF generation for MinGW (#10468)

Fortunately this is relatively straightforward - all we need to do is
switch to a non-ELF-specific way of specifying object file sections and
make sure that section-relative addresses work correctly. This is enough
to make "gdb" work on MinGW builds.