summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
...
* Suggest how to fix illegally nested foralls in GADT constructor type signaturesRyan Scott2017-08-171-0/+43
| | | | | | | | | | | | | | | | | | Summary: Although the code from #12087 isn't accepted by GHC, we can at least do a better job of letting users know what the problem is, and how to fix it. Test Plan: make test TEST=T12087 Reviewers: goldfire, austin, bgamari Reviewed By: goldfire Subscribers: rwbarton, thomie GHC Trac Issues: #12087 Differential Revision: https://phabricator.haskell.org/D3851
* Fix #13972 by producing tidier errorsRyan Scott2017-08-171-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, one could experience an error message like this: ``` Expected: T (a -> Either a b) Actual: T (a -> Either a b) ``` This makes the error message an iota clearer by tidying it first, which will instead produce: ``` Expected: T (a1 -> Either a1 b1) Actual: T (a -> Either a b) ``` Which steers users towards the understanding that the two sets of tyvars are actually different. Test Plan: make test TEST=T13972 Reviewers: simonpj, austin, bgamari, goldfire Reviewed By: goldfire Subscribers: goldfire, rwbarton, thomie GHC Trac Issues: #13972 Differential Revision: https://phabricator.haskell.org/D3820
* Allow TcDerivInfer to compile with GHC 8.0.1Ben Gamari2017-08-161-21/+21
| | | | | | | | | | | | | | | | | As of ed7a830de6a2ea74dd6bb81f8ec55b9fe0b52f28 this module uses MultiWayIf, the parsing behavior of which changed in 8.0.2 due to #10807. Reformat the code so that it compiles under both 8.0.1 and 8.0.2/8.2.1. Test Plan: Validate bootstrapping with 8.0.1 Reviewers: austin Subscribers: rwbarton, thomie, RyanGlScott GHC Trac Issues: #14130 Differential Revision: https://phabricator.haskell.org/D3863
* Speed up compilation of profiling stubsBen Gamari2017-08-161-15/+31
| | | | | | | | | | | | | | | | | | | | Here we encode the cost centre list as static data. This means that the initialization stubs are small functions which should be easy for GCC to compile, even with optimization. Fixes #7960. Test Plan: Test profiling Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #7960 Differential Revision: https://phabricator.haskell.org/D3853
* Recognize FreeBSD compiler as Clang.Gleb Popov2017-08-141-0/+3
| | | | | | | | | | Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3840
* Use a ReaderT in TcDeriv to avoid some tedious plumbingRyan Scott2017-08-143-586/+693
| | | | | | | | | | | | | | | | | | | | | | | | | | | Addresses point (2) of https://phabricator.haskell.org/D3337#107865. Before, several functions in `TcDeriv` and `TcDerivInfer` which compute an `EarlyDerivSpec` were manually threading through about 10 different arguments, which contribute to quite a lot of clutter whenever they need to be updated. To minimize this plumbing, and to make it clearer which of these 10 values are being used where, I refactored the code in `TcDeriv` and `TcDerivInfer` to use a new `DerivM` type: ```lang=haskell type DerivM = ReaderT DerivEnv TcRn ``` where `DerivEnv` contains the 10 aforementioned values. In addition to cleaning up the code, this should make some subsequent changes planned for later less noisy. Test Plan: ./validate Reviewers: austin, bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3846
* Don't drop GHCi-defined functions with -fobject-code enabledRyan Scott2017-08-141-4/+15
| | | | | | | | | | | | | | | | | | | | | The desugarer was using `targetRetainsAllBindings` as a litmus test for determining if a function was defined in interactive mode (and thus should be exported). However, there is a corner case where one can be in interactive mode and have `targetRetainsAllBindings` return `False`: if `-fobject-code` is enabled (since the target will no longer be `HscInteractive`). In such a scenario, we should fall back on a different test for determining if we are in a GHCi session. I chose to use `isInteractiveModule`, which appears to do the trick. Test Plan: make test TEST=T12091 Reviewers: austin, bgamari Subscribers: rwbarton, thomie GHC Trac Issues: #12091 Differential Revision: https://phabricator.haskell.org/D3849
* Fix #14060 by more conservatively annotating TH-reified typesRyan Scott2017-08-148-34/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before, TH was quite generous in applying kind annotations to reified type constructors whose result kind happened to mention type variables. This could result in agonizingly large reified types, so this patch aims to quell this a bit by adopting a more nuanced algorithm for determining when a tycon application deserves a kind annotation. This implements the algorithm laid out in https://ghc.haskell.org/trac/ghc/ticket/14060#comment:1. I've updated `Note [Kind annotations on TyConApps]` to reflect the new wisdom. Essentially, instead of only checking if the result kind contains free variables, we also check if any of those variables do not appear free in injective positions in the argument kinds—only then do we put on a kind annotation. Bumps `haddock` submodule. Test Plan: make test TEST=T14060 Reviewers: goldfire, austin, bgamari Reviewed By: goldfire Subscribers: rwbarton, thomie GHC Trac Issues: #14060 Differential Revision: https://phabricator.haskell.org/D3807
* Expand type synonyms during role inferenceRyan Scott2017-08-123-0/+8
| | | | | | | | | | | | | | | | | | | | | Summary: During role inference, we need to expand type synonyms, since oversaturated applications of type synonym tycons would otherwise have overly conservative roles inferred for its arguments. Fixes #14101. Test Plan: ./validate Reviewers: goldfire, austin, bgamari Reviewed By: goldfire Subscribers: rwbarton, thomie GHC Trac Issues: #14101 Differential Revision: https://phabricator.haskell.org/D3838
* Change isClosedAlgType to be TYPE-aware, and rename it to pmIsClosedTypeRyan Scott2017-08-123-138/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In a267580e4ab37115dcc33f3b8a9af67b9364da12, I somewhat awkwardly inserted a special case for `TYPE` in the `EmptyCase` coverage checker. Instead of placing it there, @mpickering noted that `isClosedAlgType` would be a better fit for it. I do just that in this patch. I also renamed `isClosedAlgType` to `pmIsClosedType`, reflecting the fact that `TYPE` technically isn't an algebraic type (it's a primitive one), and that its behavior is pattern-match coverage checking-oriented. I also moved it to `Check`, which is a better home for this function than `Type`. Luckily, the only call sites for `isClosedAlgType` were in the pattern-match coverage checker anyways, so this change is simple enough. Test Plan: ./validate Reviewers: mpickering, austin, goldfire, bgamari Reviewed By: goldfire Subscribers: rwbarton, thomie, mpickering GHC Trac Issues: #14086 Differential Revision: https://phabricator.haskell.org/D3830
* Use NonEmpty lists to represent lists of duplicate elementsRyan Scott2017-08-1213-55/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Three functions in `ListSetOps` which compute duplicate elements represent lists of duplicates of `[a]`. This is a really bad way to go about things, because these lists are guaranteed to always have at least one element (the "representative" of the duplicates), and several places in the GHC API call `head` (a partial function) on these lists of duplicates to retrieve the representative. This changes the representation of duplicates to `NonEmpty` lists instead, which allow for many partial uses of `head` to be made total. Fixes #13823. Test Plan: ./validate Reviewers: bgamari, austin, goldfire Reviewed By: bgamari Subscribers: goldfire, rwbarton, thomie GHC Trac Issues: #13823 Differential Revision: https://phabricator.haskell.org/D3823
* Don't suppress unimplemented type family warnings with DeriveAnyClassRyan Scott2017-08-123-16/+35
| | | | | | | | | | | | | | | | | | | | | | | Summary: For some asinine reason, we were suppressing warnings when deriving associated type family instances with `DeriveAnyClass`. That seems like a bad idea. Let's not do that. Along the way, I noticed that the error contexts associated with these newly emitted warnings were less than ideal, so I did some minor refactoring to improve the story there. Fixes #14094 Test Plan: ./validate Reviewers: bgamari, austin Subscribers: rwbarton, thomie GHC Trac Issues: #14094 Differential Revision: https://phabricator.haskell.org/D3828
* Split out inferConstraintsDataConArgs from inferConstraintsRyan Scott2017-08-121-21/+41
| | | | | | | | | | | | | | | | | | | | | | | Summary: Addresses point (1) of https://phabricator.haskell.org/D3337#107865. Before, `inferConstraints` awkwardly combined all of the logic needed to handle stock, newtype, and anyclass deriving. Really, though, the stock/newtype logic is quite different from the anyclass logic, so this splits off `inferConstraintsDataConArgs` (so named because it infers constraints by inspecting the types of the arguments to data constructors) from `inferConstraints` to handle the stock/newtype-specific bits. Aside from making the code somewhat clearer, this allows us to factor out superclass constraint inference, which is done regardless of deriving strategy. Test Plan: If it builds, ship it Reviewers: bgamari, austin Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3827
* Fix string escaping in JSONDmitry Malikov2017-08-061-1/+1
| | | | | It seems to that double quotes is not escaped well at the moment. We'd noticed this with @alexbiehl during the work on https://github.com/haskell/haddock/pull/645
* Don't warn when empty casing on TypeRyan Scott2017-08-051-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: `Type` (a.k.a. `TYPE LiftedRep`) can be used at the type level thanks to `TypeInType`. However, expressions like ```lang=haskell f :: Type -> Int f x = case x of {} ``` were falsely claiming that the empty case on the value of type `Type` was non-exhaustive. The reason is a bit silly: `TYPE` is technically not an empty datatype in GHC's eyes, since it's a builtin, primitive type. To convince the pattern coverage checker otherwise, this adds a special case for `TYPE`. Test Plan: make test TEST=T14086 Reviewers: gkaracha, austin, bgamari, goldfire Reviewed By: goldfire Subscribers: goldfire, rwbarton, thomie GHC Trac Issues: #14086 Differential Revision: https://phabricator.haskell.org/D3819
* Add MonadIO Q - by requiring MonadIO => QuasiOleg Grenrus2017-08-051-1/+0
| | | | | | | | | | | | Summary: This is follow-up to https://ghc.haskell.org/trac/ghc/ticket/10773 Reviewers: austin, goldfire, bgamari, RyanGlScott Reviewed By: RyanGlScott Subscribers: RyanGlScott, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3816
* Remove unneeded uses of ImplicitParamsRyan Scott2017-08-024-4/+1
| | | | | | | | | | | | | | Summary: Finish the work started in 7d1909ad110f05c8cb2fb0689ee75857ceb945f6. Test Plan: If it builds, ship it Reviewers: austin, bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3812
* Get the roles right for newtype instancesSimon Peyton Jones2017-08-022-3/+7
| | | | | | This was a simple slip, that gave rise to the bug reported in comment:13 of Trac #14045. We were supplying roles to mkAlgTyCon that didn't match the tyvars.
* Drop GHC 7.10 compatibilityRyan Scott2017-08-0129-190/+11
| | | | | | | | | | | | | | | | GHC 8.2.1 is out, so now GHC's support window only extends back to GHC 8.0. This means we can delete gobs of code that was only used for GHC 7.10 support. Hooray! Test Plan: ./validate Reviewers: hvr, bgamari, austin, goldfire, simonmar Reviewed By: bgamari Subscribers: Phyx, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3781
* Simplify OccurAnal.tagRecBindersJoachim Breitner2017-08-011-6/+3
| | | | | | | No need to mark the binders with markNonTailCalled, as they already have been marked as such in rhs_udss' via adjust. Differential Revision: https://phabricator.haskell.org/D3810
* Allow bundling pattern synonyms with exported data familiesRyan Scott2017-08-011-0/+6
| | | | | | | | | | | | | | Test Plan: make test TEST=T14058 Reviewers: mpickering, austin, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #14058 Differential Revision: https://phabricator.haskell.org/D3808
* KnownUniques: Handle DataCon wrapper namesBen Gamari2017-08-011-3/+6
| | | | | | | | | | | | | | | | | For some reason these weren't handled. I seem to remember thinking I had a reason for omitting them when writing the original patch, but I don't recall what that reason was at this point and clearly workers do show up in interface files. Test Plan: Validate against T14051 Reviewers: austin Subscribers: rwbarton, thomie, RyanGlScott GHC Trac Issues: #14051 Differential Revision: https://phabricator.haskell.org/D3805
* Typofixes [ci skip]Gabor Greif2017-08-015-5/+5
|
* A bunch of typofixesGabor Greif2017-07-3112-12/+12
|
* Use field names for all uses of datacon MatchSimon Peyton Jones2017-07-3112-34/+42
| | | | | | | This is refactoring only... elimiante all positional uses of the data constructor Match in favour of field names. No change in behaviour.
* Remove redundant goopSimon Peyton Jones2017-07-311-7/+2
| | | | See comment:22 in Trac #13594
* Reject top-level banged bindingsSimon Peyton Jones2017-07-313-15/+15
| | | | | | | | | | | | | | | Bizarrely, we were not rejecting !x = e Fix: * In the test in DsBinds.dsTopLHsBinds, use isBangedHsBind, not isBangedPatBind. (Indeed the latter dies altogther.) * Implement isBangedHsBind in HsUtils; be sure to handle AbsBinds All this was shown up by Trac #13594
* Do a bit more CSESimon Peyton Jones2017-07-311-1/+1
| | | | | | | | I discovered that in let x = MkT y in ....(MKT y |> co).... we weren't CSE'ing the (MkT y). The fix is easy.
* Improve the desugaring of -XStrictSimon Peyton Jones2017-07-3111-321/+248
| | | | | | | | | | | | | | | | | | | | | | | Trac #14035 showed that -XStrict was generating some TERRIBLE desugarings, espcially for bindings with INLINE pragmas. Reason: with -XStrict, all AbsBinds (even for non-recursive functions) went via the general-case deguaring for AbsBinds, namely "generate a tuple and select from it", even though in this case there was only one variable in the tuple. And that in turn interacts terribly badly with INLINE pragmas. This patch cleans things up: * I killed off AbsBindsSig completely, in favour of a boolean flag abs_sig in AbsBinds. See Note [The abs_sig field of AbsBinds] This allowed me to delete lots of code; and instance-method declarations can enjoy the benefits too. (They could have before, but no one had changed them to use AbsBindsSig.) * I refactored all the AbsBinds handling in DsBinds into a new function DsBinds.dsAbsBinds. This allowed me to handle the strict case uniformly
* Refactoring around FunRhsSimon Peyton Jones2017-07-317-32/+45
| | | | | * Clarify the comments around the mc_strictness field of FunRhs * Use record field names consistently for FunRhs
* Clarify comment about data family aritiesRichard Eisenberg2017-07-311-0/+5
| | | | | | as requested in #14045. [skip ci] comments only
* Add haddock markupGabor Greif2017-07-301-1/+1
|
* Typofixes [ci skip]Gabor Greif2017-07-302-5/+5
|
* Fix #14045 by omitting an unnecessary checkRichard Eisenberg2017-07-296-64/+80
| | | | | | | | | | | | | | | | | | | | | | | Previously, we checked the number of patterns in a data instances for all data families whose kind did not end in a kind variable. But, of course, undersaturating instances can happen even without the kind ending in a kind variable. So I've omitted the arity check. Data families aren't as particular about their arity as type families are (because data families can be undersaturated). Still, this change degrades error messages when instances don't have the right arity; now, instead of reporting a simple mismatch in the number of patterns, GHC reports kind errors. The new errors are fully accurate, but perhaps not as easy to work with. Still, with the new flexibility of allowing data family instances with varying numbers of patterns, I don't see a better way. This commit also improves source fidelity in some error messages, requiring more changes than really are necessary. But without these changes, error messages around mismatched associated instance heads were poor. test cases: indexed-types/should_compile/T14045, indexed-types/should_fail/T14045a
* Add rtsopts ignore and ignoreAll.Andreas Klebinger2017-07-281-1/+7
| | | | | | | | | | | | | | | | | | | | | These ignore commandline arguments for ignore and commandline as well as GHCRTS arguments for ignoreAll. Passing RTS flags given on the command line along to the program by simply skipping processing of these flags by the RTS. This fixes #12870. Test Plan: ./validate Reviewers: austin, hvr, bgamari, erikd, simonmar Reviewed By: simonmar Subscribers: Phyx, rwbarton, thomie GHC Trac Issues: #12870 Differential Revision: https://phabricator.haskell.org/D3740
* Fix hs-boot knot-tying with record wild cards.Edward Z. Yang2017-07-281-1/+8
| | | | | | | | | | | | | | | | | | Fixes #13710. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: bgamari, austin, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #13710 Differential Revision: https://phabricator.haskell.org/D3743
* Remove unnecessary GHC option from SrcLocSven Tennie2017-07-281-4/+0
| | | | | | | | | | | | This was an old workaround for #5252. Fixes #13173. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3763
* Ensure that we always link against libmBen Gamari2017-07-282-0/+15
| | | | | | | | | | | | | | | ld.gold is particularly picky that we declare all of our link dependencies on Nix. See #14022. Test Plan: Validate on Nix Reviewers: austin Subscribers: hvr, rwbarton, thomie GHC Trac Issues: #14022 Differential Revision: https://phabricator.haskell.org/D3787
* ByteCodeGen: use byte indexing for BCenvMichal Terepeta2017-07-281-184/+283
| | | | | | | | | | | | | | | | | | | | | | | | | This is another change needed for #13825 (also based on D38 by Simon Marlow). With the change, we count the stack depth in bytes (instead of words). We also introduce some `newtype`s to help with the change. Note that this only changes how `ByteCodeGen` works and shouldn't affect the generated bytecode. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Test Plan: ./validate Reviewers: bgamari, simonmar, austin, hvr Reviewed By: bgamari, simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13825 Differential Revision: https://phabricator.haskell.org/D3746
* Merge types and kinds in DsMetaRyan Scott2017-07-282-190/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Types and kinds are now the same in GHC... well, except in the code that involves Template Haskell, where types and kinds are given separate treatment. This aims to unify that treatment in the `DsMeta` module. The gist of this patch is replacing all uses of `repLKind` with `repLTy`. This is isn't quite as simple as one might imagine, since `repLTy` returns a `Core (Q Type)` (a monadic expression), whereas `repLKind` returns a `Core Kind` (a pure expression). This causes many awkward impedance mismatches. One option would be to change every combinator in `Language.Haskell.TH.Lib` to take `KindQ` as an argument instead of `Kind`. But this would be a breaking change of colossal proportions. Instead, this patch takes a somewhat different approach. This migrates the existing `Language.Haskell.TH.Lib` module to `Language.Haskell.TH.Lib.Internal`, and changes all `Kind`-related combinators in `Language.Haskell.TH.Lib.Internal` to live in `Q`. The new `Language.Haskell.TH.Lib` module then re-exports most of `Language.Haskell.TH.Lib.Internal` with the exception of the `Kind`-related combinators, for which it redefines them to be their current definitions (which don't live in `Q`). This allows us to retain backwards compatibility with previous `template-haskell` releases, but more importantly, it allows GHC to make as many changes to the `Internal` code as it wants for its purposes without fear of disrupting the public API. This solves half of #11785 (the other half being `TcSplice`). Test Plan: ./validate Reviewers: goldfire, austin, bgamari Reviewed By: goldfire Subscribers: rwbarton, thomie GHC Trac Issues: #11785 Differential Revision: https://phabricator.haskell.org/D3751
* Error eagerly after renaming failures in reifyInstancesRyan Scott2017-07-281-1/+5
| | | | | | | | | | | | | | | | | | | | Summary: Previously, if `reifyInstances` failed to discover a `Name` during renaming, it would blindy charge into typechecking, at which point GHC would become very confused at the absence of that `Name` and throw an internal error. A simple workaround is to fail eagerly after renaming errors. Test Plan: make test TEST=T13837 Reviewers: goldfire, austin, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie GHC Trac Issues: #13837 Differential Revision: https://phabricator.haskell.org/D3793
* Add DebugCallStack to piResultTySimon Peyton Jones2017-07-282-2/+2
| | | | | This was provoked by an ASSERT failure when debugging #14038, but it's a godo idea anyway.
* Do not discard insolubles in implicationsSimon Peyton Jones2017-07-286-57/+109
| | | | | | | | | | | | | | | Trac #14000 showed up two errors * In TcRnTypes.dropInsolubles we dropped all implications, which might contain the very insolubles we wanted to keep. This was an outright error, and is why the out-of-scope error was actually lost altogether in Trac #14000 * In TcSimplify.simplifyInfer, if there are definite (insoluble) errors, it's better to suppress the following ambiguity test, because the type may be bogus anyway. See TcSimplify Note [Quantification with errors]. This fix seems a bit clunky, but it'll do for now.
* Fix ASSERT failure in tc269Simon Peyton Jones2017-07-281-6/+3
| | | | | | | | This ASSERT failure (in substTy) was reported in Trac #14024. This patch gets the in-scope set right. (Does not fix tests T13822 or T13594.)
* Remove redundant constraint in contextSimon Peyton Jones2017-07-281-1/+1
|
* Fix instantiation of pattern synonymsSimon Peyton Jones2017-07-282-16/+55
| | | | | | | | | | In Check.hs (pattern match ovelap checking) we to figure out the instantiation of a pattern synonym from the type of the pattern. We were doing this utterly wrongly. Trac #13768 demonstrated this bogosity. The fix is easy; and is described in PatSyn.hs Note [Pattern synonym result type]
* Refactor tcInferApps.Richard Eisenberg2017-07-273-63/+64
| | | | | | | With the changes caused by the fix to #12369, it is now clearer how to rewrite tcInferApps and friends. This should change no behavior, but it does clean up a nasty corner of the type checker. This commit also removes some uses of substTyUnchecked.
* Fix #12369 by being more flexible with data instsRichard Eisenberg2017-07-278-183/+355
| | | | | | | | | | | | | | | | | | | | | | | | | Previously, a data family's kind had to end in `Type`, and data instances had to list all the type patterns for the family. However, both of these restrictions were unnecessary: - A data family's kind can usefully end in a kind variable `k`. See examples on #12369. - A data instance need not list all patterns, much like how a GADT-style data declaration need not list all type parameters, when a kind signature is in place. This is useful, for example, here: data family Sing (a :: k) data instance Sing :: Bool -> Type where ... This patch also improved a few error messages, as some error plumbing had to be moved around. See new Note [Arity of data families] in FamInstEnv for more info. test case: indexed-types/should_compile/T12369
* Fix #12176 by being a bit more careful instantiating.Richard Eisenberg2017-07-272-20/+34
| | | | | | | | | Previously, looking up a TyCon that said "no" to mightBeUnsaturated would then instantiate all of its invisible binders. But this is wrong for vanilla type synonyms, whose RHS kind might legitimately start with invisible binders. So a little more care is taken now, only to instantiate those invisible binders that need to be (so that the TyCon isn't unsaturated).
* Fix #11963 by checking for more mixed type/kindsRichard Eisenberg2017-07-271-5/+20
| | | | | | | This is a straightforward fix -- there were just some omitted checks. test case: typecheck/should_fail/T11963