summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Fix infix record field fixity (#11167 and #11173).Adam Gundry2015-12-118-26/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This extends D1585 with proper support for infix duplicate record fields. In particular, it is now possible to declare record fields as infix in a module for which `DuplicateRecordFields` is enabled, fixity is looked up correctly and a readable (although unpleasant) error message is generated if multiple fields with different fixities are in scope. As a bonus, `DEPRECATED` and `WARNING` pragmas now work for duplicate record fields. The pragma applies to all fields with the given label. In addition, a couple of minor `DuplicateRecordFields` bugs, which were pinpointed by the `T11167_ambig` test case, are fixed by this patch: - Ambiguous infix fields can now be disambiguated by putting a type signature on the first argument - Polymorphic type constructor signatures (such as `ContT () IO a` in `T11167_ambig`) now work for disambiguation Parts of this patch are from D1585 authored by @KaneTW. Test Plan: New tests added. Reviewers: KaneTW, bgamari, austin Reviewed By: bgamari Subscribers: thomie, hvr Differential Revision: https://phabricator.haskell.org/D1600 GHC Trac Issues: #11167, #11173
* Improved data family export documentationDavid Kraeutmann2015-12-111-2/+3
| | | | | | | | | | | | Reviewers: simonpj, austin, bgamari Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1587 GHC Trac Issues: #11164
* Make sure PatSyns only get added once to tcg_patsynsMatthew Pickering2015-12-113-14/+11
| | | | | | | | | | | | | | Summary: Before, `PatSyn`s were getting added twice to `tcg_patsyns` so when inspecting afterwards there were duplicates in the list. This makes sure that only they only get added once. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1597
* More typos in comments/docsGabor Greif2015-12-098-10/+10
|
* Comments onlySimon Peyton Jones2015-12-091-5/+4
|
* Fix DeriveAnyClass (Trac #9968)Simon Peyton Jones2015-12-092-157/+208
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main issue concerned things like data T a = MkT a deriving( C Int ) which is supposed to generate instance C Int (T a) where {} But the 'Int' argument (called cls_tys in the code) wasn't even being passed to inferConstraints and mk_data_eqn, so it really had no chance. DeriveAnyClass came along after this code was written! Anyway I did quite a bit of tidying up in inferConstraints. Also I discovered that this case was not covered at all data T a b = MkT a b deriving( Bifunctor ) What constraints should we generate for the instance context? We can deal with classes whose last arg has kind *, like Eq, Ord; or (* -> *), like Functor, Traversable. But we really don't have a story for classes whose last arg has kind (* -> * -> *). So I augmented checkSideConditions to check for that and give a sensible error message. ToDo: update the user manual.
* Add missing whitespace in toArgs' error msgHerbert Valerio Riedel2015-12-081-2/+2
| | | | Differential Revision: https://phabricator.haskell.org/D1591
* An assortment of typosGabor Greif2015-12-085-7/+7
|
* Comments about polymorphic recursionSimon Peyton Jones2015-12-082-10/+49
| | | | See Trac #11176
* Comments onlySimon Peyton Jones2015-12-081-4/+24
|
* Fix typo sneaked in with fd3b845c01aa26b6e5Herbert Valerio Riedel2015-12-081-2/+2
|
* Fix double MaybeT instanceHerbert Valerio Riedel2015-12-081-4/+0
| | | | | | This is a fixup to fd3b845c01aa26b6e5cd12c00af59e5468e21b1b which didn't take into account 09333313f32be975faf9158fcd3648489d78ad82 having pushed as well.
* Make HasDynFlags more transformers friendlyHerbert Valerio Riedel2015-12-083-12/+43
| | | | | | | | | | | | | | | | | Ideally, we'd have the more general instance (MonadTrans t, Monad m, HasDynFlags m) => HasDynFlags (t m) where getDynFlags = lift getDynFlags definition. However, that one would overlap with the `HasDynFlags (GhcT m)` instance. Instead we define instances for a couple of common Monad transformers explicitly in order to avoid nasty overlapping instances. This is a preparatory refactoring for #10874 Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D1581
* Get rid of tcView altogetherÖmer Sinan Ağacan2015-12-078-69/+58
| | | | | | | | | | | | | This is just a trivial renaming that implements a ToDo mentioned in a comment in Type.hs. Adding Simon as reviewer since he added the ToDo comment. Reviewers: simonpj, austin, goldfire, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1584
* Re-use `transformers`'s `MaybeT` rather than our ownHerbert Valerio Riedel2015-12-071-56/+4
| | | | | | | | | The now removed `MaybeT` type was originally added back in 2008 via bc845b714132a897032502536fea8cd018ce325b Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1583
* Move checking for missing signatures to RnNames.reportUnusedNamesEric Seidel2015-12-074-119/+119
| | | | | | | | | | | | | | | | | | Checking for missing signatures before renaming the export list is prone to errors, so we now perform the check in `reportUnusedNames` at which point everything has been renamed. Test Plan: validate, new test case is T10908 Reviewers: goldfire, simonpj, austin, bgamari Subscribers: thomie Projects: #ghc Differential Revision: https://phabricator.haskell.org/D1561 GHC Trac Issues: #10908
* Refactor ConDeclAlan Zimmerman2015-12-0715-333/+418
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ConDecl type in HsDecls is an uneasy compromise. For the most part, HsSyn directly reflects the syntax written by the programmer; and that gives just the right "pegs" on which to hang Alan's API annotations. But ConDecl doesn't properly reflect the syntax of Haskell-98 and GADT-style data type declarations. To be concrete, here's a draft new data type ```lang=hs data ConDecl name | ConDeclGADT { con_names :: [Located name] , con_type :: LHsSigType name -- The type after the ‘::’ , con_doc :: Maybe LHsDocString } | ConDeclH98 { con_name :: Located name , con_qvars :: Maybe (LHsQTyVars name) -- User-written forall (if any), and its implicit -- kind variables -- Non-Nothing needs -XExistentialQuantification , con_cxt :: Maybe (LHsContext name) -- ^ User-written context (if any) , con_details :: HsConDeclDetails name -- ^ Arguments , con_doc :: Maybe LHsDocString -- ^ A possible Haddock comment. } deriving (Typeable) ``` Note that For GADTs, just keep a type. That's what the user writes. NB:HsType can represent records on the LHS of an arrow: { x:Int,y:Bool} -> T con_qvars and con_cxt are both Maybe because they are both optional (the forall and the context of an existential data type For ConDeclGADT the type variables of the data type do not scope over the con_type; whereas for ConDeclH98 they do scope over con_cxt and con_details. Updates haddock submodule. Test Plan: ./validate Reviewers: simonpj, erikd, hvr, goldfire, austin, bgamari Subscribers: erikd, goldfire, thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1558 GHC Trac Issues: #11028
* Use TypeLits in the meta-data encoding of GHC.GenericsRyanGlScott2015-12-074-316/+146
| | | | | | | | | | | | | | Test Plan: Validate. Reviewers: simonpj, goldfire, hvr, dreixel, kosmikus, austin, bgamari Reviewed By: kosmikus, austin, bgamari Subscribers: RyanGlScott, Fuuzetsu, bgamari, thomie, carter, dreixel Differential Revision: https://phabricator.haskell.org/D493 GHC Trac Issues: #9766
* Add isImport, isDecl, and isStmt functions to GHC APIRoman Shatsov2015-12-072-0/+38
| | | | | | | | | | | | Reviewers: austin, thomie, bgamari Reviewed By: thomie, bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D1518 GHC Trac Issues: #9015
* Re-export data family when exporting a data instance without an export listDavid Kraeutmann2015-12-071-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Whenever a data instance is exported, the corresponding data family is exported, too. This allows one to write ``` -- Foo.hs module Foo where data family T a -- Bar.hs module Bar where import Foo data instance T Int = MkT -- Baz.hs module Baz where import Bar (T(MkT)) ``` In previous versions of GHC, this required a workaround explicit export list in `Bar`. Reviewers: bgamari, goldfire, austin Reviewed By: bgamari, goldfire Subscribers: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D1573 GHC Trac Issues: #11164
* Implement new `-fwarn-noncanonical-monoid-instances`Herbert Valerio Riedel2015-12-062-42/+112
| | | | | | | | | | | | | | | | This is similiar to the `-fwarn-noncanonical-monad-instances` warning implemented via #11128, but applies to `Semigroup`/`Monoid` instead and the `(<>)`/`mappend` methods (of which `mappend` is planned to move out of `Monoid` at some point in the future being redundant and thus error-prone). This warning is contained in `-Wcompat` but not in `-Wall`. This addresses #11150 Reviewed By: quchen Differential Revision: https://phabricator.haskell.org/D1553
* pmcheck: Comments about undecidability of literal equalityGeorge Karachalias2015-12-053-7/+73
|
* pmcheck: Comments about term equality representationGeorge Karachalias2015-12-052-1/+65
|
* StgCmmMonad: Implement Outputable instance for Sequel for debuggingÖmer Sinan Ağacan2015-12-041-0/+4
| | | | | | | | | | Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1563
* Comments onlySimon Peyton Jones2015-12-041-8/+5
|
* Tidy user type errors in checkValidTypeSimon Peyton Jones2015-12-042-13/+22
| | | | | | | | | | | | | | | | | | Trac #11144 showed that we need to tidy the type in the error message generated in TcValidity.checkUserTypeError. This is still unsatisfactory. checkValidType was originally supposed to be called only on types gotten directly from user-written HsTypes. So its error messages do no tidying. But TcBinds calls it checkValidType on an /inferred/ type, which may need tidying. Still this at least fixes the bad error message in CustomTypeErrors02, which was the original ticket. Some other small refactorings: * Remove unused Kind result of getUserTypeErrorMsg * Rename isUserErrorTy --> userTypeError_maybe
* Minor refactoring of user type errorsSimon Peyton Jones2015-12-043-10/+11
| | | | | * Remove unused Kind result of getUserTypeErrorMsg * Rename isUserErrorTy --> userTypeError_maybe
* Fix egregious error in eta-reduction of data familiesSimon Peyton Jones2015-12-042-65/+87
| | | | | | | | | | | | This terrible and long-standing bug was shown up by Trac #11148. We are trying to eta-reduce a data family instance, so that we can then derive Functor or Generic. But we were assuming, for absolutely not reason whatsoever, that the type variables were lined up in a convenient order. The fact that it ever worked was a fluke. This patch fixes it properly. Main change is in eta_reduce in TcInstDcls.tcDataFamInstDecl
* Make -dppr-debug show contents of (TypeError ...)Simon Peyton Jones2015-12-041-1/+3
| | | | Just for debugging
* Wibbles onlySimon Peyton Jones2015-12-041-4/+4
|
* Add derived constraints for wildcard signaturesSimon Peyton Jones2015-12-041-35/+55
| | | | | | This fixes Trac #11016 See Note [Add deriveds for signature contexts] in TcSimplify]
* Case-of-empty-alts is trivial (Trac #11155)Simon Peyton Jones2015-12-042-10/+30
| | | | | | | | | | As you'll see from Trac #11155, the code generator was confused by a binding let x = y in .... Why did that happen? Because of a (case y of {}) expression on the RHS. The right thing is just to expand what a "trivial" expression is. See Note [Empty case is trivial] in CoreUtils.
* Make callToPats deterministic in SpecConstrBartosz Nitka2015-12-041-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a non-determinism bug where where depending on the order of uniques allocated, the specialized workers would have different order of arguments. Compare: ``` $s$wgo_s1CN :: Int# -> Int -> Int# [LclId, Arity=2, Str=DmdType <L,U><L,U>] $s$wgo_s1CN = \ (sc_s1CI :: Int#) (sc_s1CJ :: Int) -> case tagToEnum# @ Bool (<=# sc_s1CI 0#) of _ [Occ=Dead] { False -> $wgo_s1BU (Just @ Int (I# (-# sc_s1CI 1#))) (Just @ Int sc_s1CJ); True -> 0# } ``` vs ``` $s$wgo_s18mTj :: Int -> Int# -> Int# [LclId, Arity=2, Str=DmdType <L,U><L,U>] $s$wgo_s18mTj = \ (sc_s18mTn :: Int) (sc_s18mTo :: Int#) -> case tagToEnum# @ Bool (<=# sc_s18mTo 0#) of _ [Occ=Dead] { False -> $wgo_s18mUc (Just @ Int (I# (-# sc_s18mTo 1#))) (Just @ Int sc_s18mTn); True -> 0# } ``` Test Plan: I've added a new testcase ./validate Reviewers: simonmar, simonpj, austin, goldfire, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1508 GHC Trac Issues: #4012
* Check: More Clang/CPP wibblesBen Gamari2015-12-041-5/+5
|
* PmExpr: Fix CPP unacceptable too clang's CPPBen Gamari2015-12-041-1/+1
|
* Remove unused import in deSugar/TmOracle.hsGeorge Karachalias2015-12-041-1/+0
|
* Improve performance for PM check on literals (Fixes #11160 and #11161)George Karachalias2015-12-043-329/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two changes: 1. Instead of generating constraints of the form (x ~ e) (as we do in the paper), generate constraints of the form (e ~ e). The term oracle (`tmOracle` in deSugar/TmOracle.hs) is not really efficient and in the presence of many (x ~ e) constraints behaves quadratically. For literals, constraints of the form (False ~ (x ~ lit)) are pretty common, so if we start with { y ~ False, y ~ (x ~ lit) } we end up givng to the solver (a) twice as many constraints as we need and (b) half of them trigger the solver's weakness. This fixes #11160. 2. Treat two overloaded literals that look different as different. This is not entirely correct but it is what both the previous and the current check did. I had the ambitious plan to do the *right thing* (equality between overloaded literals is undecidable in the general case) and just use this assumption when issuing the warnings. It seems to generate much more constraints than I expected (breaks #11161) so I just do it immediately now instead of generating everything and filtering afterwards. Even if it is not (strictly speaking) correct, we have the following: * Gives the "expected" warnings (the ones Ocaml or the previous algorithm would give) and, * Most importantly, it is safe. Unless a catch-all clause exists, a match against literals is always non-exhaustive. So, effectively this affects only what is shown to the user (and, evidently, performance!).
* Kill redundant patternsBen Gamari2015-12-033-10/+0
| | | | | George's new exhaustiveness checker now realizes these are impossible. Yay!
* Fix haddock syntaxBen Gamari2015-12-031-3/+8
| | | | Sadly we can't annotate the elements of a tuple
* Revert "Create empty dump files when there was nothing to dump"Ben Gamari2015-12-033-71/+30
| | | | | This reverts commit 8cba907ad404ba4005558b5a8966390159938172 which broke `-ddump-to-file`.
* Major Overhaul of Pattern Match Checking (Fixes #595)George Karachalias2015-12-0323-860/+2483
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adresses several problems concerned with exhaustiveness and redundancy checking of pattern matching. The list of improvements includes: * Making the check type-aware (handles GADTs, Type Families, DataKinds, etc.). This fixes #4139, #3927, #8970 and other related tickets. * Making the check laziness-aware. Cases that are overlapped but affect evaluation are issued now with "Patterns have inaccessible right hand side". Additionally, "Patterns are overlapped" is now replaced by "Patterns are redundant". * Improved messages for literals. This addresses tickets #5724, #2204, etc. * Improved reasoning concerning cases where simple and overloaded patterns are matched (See #322). * Substantially improved reasoning for pattern guards. Addresses #3078. * OverloadedLists extension does not break exhaustiveness checking anymore (addresses #9951). Note that in general this cannot be handled but if we know that an argument has type '[a]', we treat it as a list since, the instance of 'IsList' gives the identity for both 'fromList' and 'toList'. If the type is not clear or is not the list type, then the check cannot do much still. I am a bit concerned about OverlappingInstances though, since one may override the '[a]' instance with e.g. an '[Int]' instance that is not the identity. * Improved reasoning for nested pattern matching (partial solution). Now we propagate type and (some) term constraints deeper when checking, so we can detect more inconsistencies. For example, this is needed for #4139. I am still not satisfied with several things but I would like to address at least the following before the next release: Term constraints are too many and not printed for non-exhaustive matches (with the exception of literals). This sometimes results in two identical (in appearance) uncovered warnings. Unless we actually show their difference, I would like to have a single warning.
* ErrUtils: Spruce up HaddocksBen Gamari2015-12-021-26/+33
| | | | This is a pretty commonly needed module; Haddocks are worth the effort.
* Create empty dump files when there was nothing to dumpVladimir Trubilov2015-12-023-31/+73
| | | | | | | | | | | | | | | | | | | | | This patch creates empty dump file when GHC was run with `-ddump-rule-firings` (or `-ddump-rule-rewrites`) and `-ddump-to-file` specified, and there were no rules applied. If dump already exists it will be overwritten by empty one. Test Plan: ./validate Reviewers: austin, thomie, bgamari Reviewed By: thomie, bgamari Subscribers: thomie Projects: #ghc Differential Revision: https://phabricator.haskell.org/D1514 GHC Trac Issues: #10320
* Avoid panic due to partial ieNameEric Seidel2015-12-021-1/+1
| | | | | | | | | | | | HsImpExp.ieName is partial and fails when given e.g. `module X` solution: use ieNames instead which returns a list of names instead of a single name. Reviewed By: bgamari, austin Differential Revision: https://phabricator.haskell.org/D1551 GHC Trac Issues: #11077
* Move Stg-specific code from DynFlags to SimplStgÖmer Sinan Ağacan2015-12-022-26/+22
| | | | | | Reviewed By: bgamari, austin Differential Revision: https://phabricator.haskell.org/D1552
* StgSyn: Remove unused SRT constructorÖmer Sinan Ağacan2015-12-022-6/+0
| | | | | | Reviewed By: bgamari, austin Differential Revision: https://phabricator.haskell.org/D1560
* Comments (TcSMonad)Simon Peyton Jones2015-12-021-4/+8
|
* Comments only (isIrrefutablePat)Simon Peyton Jones2015-12-022-2/+11
|
* Implement more deterministic operations and document themBartosz Nitka2015-12-0211-90/+380
| | | | | | | | | | | | | | | | I will need them for the future determinism fixes. Test Plan: ./validate Reviewers: simonpj, goldfire, bgamari, austin, hvr, simonmar Reviewed By: simonpj, simonmar Subscribers: osa1, thomie Differential Revision: https://phabricator.haskell.org/D1537 GHC Trac Issues: #4012
* Make the order of fixities in the iface file deterministicBartosz Nitka2015-12-021-1/+5
| | | | | | | | | | | | | | | | | This normalizes the order of written fixities by sorting by `OccName` making it independent of `Unique` order. Test Plan: I've added a new testcase Reviewers: austin, bgamari, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1557 GHC Trac Issues: #4012