summaryrefslogtreecommitdiff
path: root/compiler/rename
Commit message (Collapse)AuthorAgeFilesLines
* Add -fdefer-typed-holes flag which defers hole errors to runtime.Merijn Verstraaten2014-11-211-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As proposed by Richard on Trac. This patch adds a new flag -fdefer-typed-holes and changes the semantics of the -fno-warn-typed-holes flag. To summarise, by default GHC has typed holes enabled and produces a compile error when it encounters a typed hole. When -fdefer-type-errors OR -fdefer-typed-holes is enabled, hole errors are converted to warnings and result in runtime errors when evaluated. The warning flag -fwarn-typed-holes is on by default. Without -fdefer-type-errors or -fdefer-typed-holes this flag is a no-op, since typed holes are an error under these conditions. If either of the defer flags are enabled (converting typed hole errors into warnings) the -fno-warn-typed-holes flag disables the warnings. This means compilation silently succeeds and evaluating a hole will produce a runtime error. The rationale behind allowing typed holes warnings to be silenced is that tools like Syntastic for vim highlight warnings and hole warnings may be undesirable. Signed-off-by: Merijn Verstraaten <merijn@inconsistent.nl> Test Plan: validate Reviewers: austin, simonpj, thomie Reviewed By: simonpj, thomie Subscribers: Fuuzetsu, thomie, carter Differential Revision: https://phabricator.haskell.org/D442 GHC Trac Issues: #9497 Conflicts: compiler/main/DynFlags.hs
* Capture original source for literalsAlan Zimmerman2014-11-212-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Make HsLit and OverLitVal have original source strings, for source to source conversions using the GHC API This is part of the ongoing AST Annotations work, as captured in https://ghc.haskell.org/trac/ghc/wiki/GhcAstAnnotations and https://ghc.haskell.org/trac/ghc/ticket/9628#comment:28 The motivations for the literals is as follows ```lang=haskell x,y :: Int x = 0003 y = 0x04 s :: String s = "\x20" c :: Char c = '\x20' d :: Double d = 0.00 blah = x where charH = '\x41'# intH = 0004# wordH = 005## floatH = 3.20# doubleH = 04.16## x = 1 ``` Test Plan: ./sh validate Reviewers: simonpj, austin Reviewed By: simonpj, austin Subscribers: thomie, goldfire, carter, simonmar Differential Revision: https://phabricator.haskell.org/D412 GHC Trac Issues: #9628
* AST changes to prepare for API annotations, for #9628Alan Zimmerman2014-11-217-165/+186
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: AST changes to prepare for API annotations Add locations to parts of the AST so that API annotations can then be added. The outline of the whole process is captured here https://ghc.haskell.org/trac/ghc/wiki/GhcAstAnnotations This change updates the haddock submodule. Test Plan: sh ./validate Reviewers: austin, simonpj, Mikolaj Reviewed By: simonpj, Mikolaj Subscribers: thomie, goldfire, carter Differential Revision: https://phabricator.haskell.org/D426 GHC Trac Issues: #9628
* Fix #9824 by not warning about unused matches in pattern quotes.Richard Eisenberg2014-11-211-0/+3
|
* Fix #1476 by making splice patterns work.Richard Eisenberg2014-11-213-12/+39
| | | | | | | | | Unfortunately, splice patterns in brackets still do not work because we don't run splices in brackets. Without running a pattern splice, we can't know what variables it binds, so we're stuck. This is still a substantial improvement, and it may be the best we can do. Still must document new behavior.
* Fix Trac #9815Simon Peyton Jones2014-11-211-4/+10
| | | | | | | | | | | Dot-dot record-wildcard notation is simply illegal for constructors without any named fields, but that was neither documented nor checked. This patch does so - Make the check in RnPat - Add test T9815 - Fix CmmLayoutStack which was using the illegal form (!) - Document in user manual
* Comments onlySimon Peyton Jones2014-11-211-1/+0
|
* Add support for pattern synonym type signatures.Dr. ERDI Gergo2014-11-201-18/+24
| | | | | | | | | | | | Syntax is of the form pattern P :: (Prov b) => (Req a) => a -> b -> Int -> T a which declares a pattern synonym called `P`, with argument types `a`, `b`, and `Int`, and result type `T a`, with provided context `(Prov b)` and required context `(Req a)`. The Haddock submodule is also updated to use this new syntax in generated docs.
* Fix #9066.Richard Eisenberg2014-11-121-21/+36
| | | | | | | | | | When splicing in a fixity declaration, look for both term-level things and type-level things. This requires some changes elsewhere in the code to allow for more flexibility when looking up Exact names, which can be assigned the wrong namespace during fixity declaration conversion. See the ticket for more info.
* Move expansion of 'assert' from renamer to typecheckerSimon Peyton Jones2014-11-061-37/+1
| | | | | This improves error messages when there is a type error, fixing Trac #9774
* A little refactoring of HsSplice and friendsSimon Peyton Jones2014-11-041-26/+27
| | | | | | | Plus adding comments. The most substantive change is that PendingTcSplice becomes a proper data type rather than a pair; and PendingRnSplice uses it
* Tweak the error message for pattern synonym methods,Dr. ERDI Gergo2014-11-021-1/+1
| | | | since they are disallowed both in class and instance declarations
* Bring unbound tyvars into scope during reifyInstances.Richard Eisenberg2014-11-011-0/+7
| | | | Fix #9262.
* rnMethodBind: reject pattern synonyms in instance definitions (fixes #9705)Dr. ERDI Gergo2014-11-011-0/+10
|
* remove old .NET related codeYuras Shumovich2014-10-311-4/+0
| | | | | | | | | | | | | | Summary: It seems to be dead anyway. Also update Haddock submodule. Test Plan: validate Reviewers: austin Reviewed By: austin Subscribers: thomie, goldfire, carter, simonmar Differential Revision: https://phabricator.haskell.org/D357
* Implementation of hsig (module signatures), per #9252Edward Z. Yang2014-10-243-89/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Module signatures, like hs-boot files, are Haskell modules which omit value definitions and contain only signatures. This patchset implements one particular aspect of module signature, namely compiling them against a concrete implementation. It works like this: when we compile an hsig file, we must be told (via the -sig-of flag) what module this signature is implementing. The signature is compiled into an interface file which reexports precisely the entities mentioned in the signature file. We also verify that the interface is compatible with the implementation. This feature is useful in a few situations: 1. Like explicit import lists, signatures can be used to reduce sensitivity to upstream changes. However, a signature can be defined once and then reused by many modules. 2. Signatures can be used to quickly check if a new upstream version is compatible, by typechecking just the signatures and not the actual modules. 3. A signature can be used to mediate separate modular development, where the signature is used as a placeholder for functionality which is loaded in later. (This is only half useful at the moment, since typechecking against signatures without implementations is not implemented in this patchset.) Unlike hs-boot files, hsig files impose no performance overhead. This patchset punts on the type class instances (and type families) problem: instances simply leak from the implementation to the signature. You can explicitly specify what instances you expect to have, and those will be checked, but you may get more instances than you asked for. Our eventual plan is to allow hiding instances, but to consider all transitively reachable instances when considering overlap and soundness. ToDo: signature merging: when a module is provided by multiple signatures for the same base implementation, we should not consider this ambiguous. ToDo: at the moment, signatures do not constitute use-sites, so if you write a signature for a deprecated function, you won't get a warning when you compile the signature. Future work: The ability to feed in shaping information so that we can take advantage of more type equalities than might be immediately evident. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate and new tests Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, ezyang, carter, goldfire Differential Revision: https://phabricator.haskell.org/D130 GHC Trac Issues: #9252
* Fix comment typos: lll -> ll, THe -> TheJan Stolarek2014-10-141-1/+1
|
* Complain about illegal type literals in renamer, not parserSimon Peyton Jones2014-09-261-2/+1
| | | | | | A premature complaint was causing Trac #9634. Acutally this change also simplifies the lexer and eliminates duplication. (The renamer was already making the check, as it happens.)
* Remove a few redundant `-fno-warn-tabs`sHerbert Valerio Riedel2014-09-251-6/+0
|
* `M-x delete-trailing-whitespace` & `M-x untabify`Herbert Valerio Riedel2014-09-241-22/+22
|
* Export `Monoid(..)`/`Foldable(..)`/`Traversable(..)` from PreludeHerbert Valerio Riedel2014-09-212-0/+5
| | | | | | | | | | | | | | | This finally exposes also the methods of these 3 classes in the Prelude in order to allow to define basic class instances w/o needing imports. This almost completes the primary goal of #9586 NOTE: `fold`, `foldl'`, `foldr'`, and `toList` are not exposed yet, as they require upstream fixes for at least `containers` and `bytestring`, and are not required for defining basic instances. Reviewed By: ekmett, austin Differential Revision: https://phabricator.haskell.org/D236
* Add -fwarn-context-quantification (#4426)Krzysztof Gogolewski2014-09-182-5/+57
| | | | | | | | | | | | | | | | | | | | | | Summary: This warning (enabled by default) reports places where a context implicitly binds a type variable, for example type T a = {-forall m.-} Monad m => a -> m a Also update Haddock submodule. Test Plan: validate Reviewers: hvr, goldfire, simonpj, austin Reviewed By: austin Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D211 GHC Trac Issues: #4426
* Make Applicative a superclass of MonadAustin Seipp2014-09-093-12/+12
| | | | | | | | | | | | | | | | | | | | | Summary: This includes pretty much all the changes needed to make `Applicative` a superclass of `Monad` finally. There's mostly reshuffling in the interests of avoid orphans and boot files, but luckily we can resolve all of them, pretty much. The only catch was that Alternative/MonadPlus also had to go into Prelude to avoid this. As a result, we must update the hsc2hs and haddock submodules. Signed-off-by: Austin Seipp <austin@well-typed.com> Test Plan: Build things, they might not explode horribly. Reviewers: hvr, simonmar Subscribers: simonmar Differential Revision: https://phabricator.haskell.org/D13
* PostTcType replaced with TypeAnnotAlan Zimmerman2014-09-067-255/+282
| | | | | | | | | | | | | | | | | | | | | Summary: This is a first step toward allowing generic traversals of the AST without 'landmines', by removing the `panic`s located throughout `placeHolderType`, `placeHolderKind` & co. See more on the discussion at https://www.mail-archive.com/ghc-devs@haskell.org/msg05564.html (This also makes a corresponding update to the `haddock` submodule.) Test Plan: `sh validate` and new tests pass. Reviewers: austin, simonpj, goldfire Reviewed By: austin, simonpj, goldfire Subscribers: edsko, Fuuzetsu, thomasw, holzensp, goldfire, simonmar, relrod, ezyang, carter Projects: #ghc Differential Revision: https://phabricator.haskell.org/D157
* Typos in commentsGabor Greif2014-08-291-1/+1
|
* Two buglets in record wild-cards (Trac #9436 and #9437)Simon Peyton Jones2014-08-252-10/+25
| | | | | | | of named fields, whereas the code in RnPat.rnHsRecFields is much better set up to do so. Both easily fixed.
* Add note about renaming of pattern synonym wrappersDr. ERDI Gergo2014-07-291-0/+27
|
* Refactor PatSynBind so that we can pass around PSBs instead of several argumentsDr. ERDI Gergo2014-07-291-22/+32
|
* When computing minimal recursive sets of bindings, don't include references ↵Dr. ERDI Gergo2014-07-291-1/+1
| | | | | | in wrapper definitions for explicitly-bidirectional pattern synonyms
* Add renamer support for explicitly-bidirectional pattern synonymsDr. ERDI Gergo2014-07-291-5/+9
|
* Refactor FFI error messagesSimon Peyton Jones2014-07-251-36/+36
| | | | | | | | | | | | | | This patch was provoked by Trac #5610, which I finally got a moment to look at. In the end I added a new data type ErrUtils.Validity, data Validity = IsValid -- Everything is fine | NotValid MsgDoc -- A problem, and some indication of why with some suitable combinators, and used it where appropriate (which touches quite a few modules). The main payoff is that error messages improve for FFI type validation.
* Rename PackageId to PackageKey, distinguishing it from Cabal's PackageId.Edward Z. Yang2014-07-212-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, both Cabal and GHC defined the type PackageId, and we expected them to be roughly equivalent (but represented differently). This refactoring separates these two notions. A package ID is a user-visible identifier; it's the thing you write in a Cabal file, e.g. containers-0.9. The components of this ID are semantically meaningful, and decompose into a package name and a package vrsion. A package key is an opaque identifier used by GHC to generate linking symbols. Presently, it just consists of a package name and a package version, but pursuant to #9265 we are planning to extend it to record other information. Within a single executable, it uniquely identifies a package. It is *not* an InstalledPackageId, as the choice of a package key affects the ABI of a package (whereas an InstalledPackageId is computed after compilation.) Cabal computes a package key for the package and passes it to GHC using -package-name (now *extremely* misnamed). As an added bonus, we don't have to worry about shadowing anymore. As a follow on, we should introduce -current-package-key having the same role as -package-name, and deprecate the old flag. This commit is just renaming. The haddock submodule needed to be updated. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D79 Conflicts: compiler/main/HscTypes.lhs compiler/main/Packages.lhs utils/haddock
* Entirely re-jig the handling of default type-family instances (fixes Trac #9063)Simon Peyton Jones2014-07-151-15/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | In looking at Trac #9063 I decided to re-design the default instances for associated type synonyms. Previously it was all jolly complicated, to support generality that no one wanted, and was arguably undesirable. Specifically * The default instance for an associated type can have only type variables on the LHS. (Not type patterns.) * There can be at most one default instances declaration for each associated type. To achieve this I had to do a surprisingly large amount of refactoring of HsSyn, specifically to parameterise HsDecls.TyFamEqn over the type of the LHS patterns. That change in HsDecls has a (trivial) knock-on effect in Haddock, so this commit does a submodule update too. The net result is good though. The code is simpler; the language specification is simpler. Happy days. Trac #9263 and #9264 are thereby fixed as well.
* Remove unused parameter in rnHsTyVarJan Stolarek2014-07-111-10/+9
|
* Replace thenM/thenM_ with do-notation in RnExprJan Stolarek2014-07-011-126/+104
|
* Overlapable pragmas for individual instances (#9242)Iavor S. Diatchki2014-06-291-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Programmers may provide a pragma immediately after the `instance` keyword to control the overlap/incoherence behavior for individual instances. For example: instance {-# OVERLAP #-} C a where ... I chose this notation, rather than the other two outlined in the ticket for these reasons: 1. Having the pragma after the type looks odd, I think. 2. Having the pragma after there `where` does not work for stand-alone derived instances I have implemented 3 pragams: 1. NO_OVERLAP 2. OVERLAP 3. INCOHERENT These correspond directly to the internal modes currently supported by GHC. If a pragma is specified, it will be used no matter what flags are turned on. For example, putting `NO_OVERLAP` on an instance will mark it as non-overlapping, even if `OVERLAPPIN_INSTANCES` is turned on for the module.
* Better debug printingSimon Peyton Jones2014-06-121-4/+9
|
* supress warning of bang wildcard pattern-binding (i.e. let !_ = rhs). This ↵Guido Zayas2014-06-061-2/+3
| | | | fixes #9127
* Report all possible results from related name spacesJoachim Breitner2014-06-061-5/+9
| | | | | instead of just one matching directly. This is an alternative way to fix ticket #9177.
* Suggest Int when user writes intJoachim Breitner2014-06-061-0/+1
| | | | and the other way around. This fixes #9177.
* Tweak commentsGabor Greif2014-06-051-4/+4
|
* Emit error in case of duplicate GRE; fixes #7241Yuras Shumovich2014-06-051-7/+14
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Fix egregious instantiation bug in matchOneConLike (fixing Trac #9023)Simon Peyton Jones2014-06-051-1/+1
| | | | | | | | | | | | | | | We simply weren't giving anything like the right instantiating types to patSynInstArgTys in matchOneConLike. To get these instantiating types would have involved matching the result type of the pattern synonym with the pattern type, which is tiresome. So instead I changed ConPatOut so that instead of recording the type of the *whole* pattern (in old field pat_ty), it not records the *instantiating* types (in new field pat_arg_tys). Then we canuse TcHsSyn.conLikeResTy to get the pattern type when needed. There are lots of knock-on incidental effects, but they mostly made the code simpler, so I'm happy.
* Do pretty-printing of TyThings via IfaceDecl (Trac #7730)Simon Peyton Jones2014-06-031-19/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All the initial work on this was done fy 'archblob' (fcsernik@gmail.com); thank you! I reviewed the patch, started some tidying, up and then ended up in a huge swamp of changes, not all of which I can remember now. But: * To suppress kind arguments when we have -fno-print-explicit-kinds, - IfaceTyConApp argument types are in a tagged list IfaceTcArgs * To allow overloaded types to be printed with =>, add IfaceDFunTy to IfaceType. * When printing data/type family instances for the user, I've made them print out an informative RHS, which is a new feature. Thus ghci> info T data family T a data instance T Int = T1 Int Int data instance T Bool = T2 * In implementation terms, pprIfaceDecl has just one "context" argument, of type IfaceSyn.ShowSub, which says - How to print the binders of the decl see note [Printing IfaceDecl binders] in IfaceSyn - Which sub-comoponents (eg constructors) to print * Moved FastStringEnv from RnEnv to OccName It all took a ridiculously long time to do. But it's done!
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-158-7/+14
| | | | | | | | | | | | | | | | | | In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been reorganized, while following the convention, to - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before any `{-# OPTIONS_GHC #-}`-lines. - Moreover, if the list of language extensions fit into a single `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each individual language extension. In both cases, try to keep the enumeration alphabetically ordered. (The latter layout is preferable as it's more diff-friendly) While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
* Second go at fixing #9061Simon Peyton Jones2014-05-061-22/+24
| | | | | My first attempt introduce a bug in -fprint-minimal-imports, but fortunately a regression test caught it.
* Fix over-zealous unused-import warningSimon Peyton Jones2014-05-051-4/+20
| | | | | | See Note [Un-warnable import decls] in RnNames. Fixes Trac #9061.
* Take account of the AvailTC invariant when importingSimon Peyton Jones2014-04-181-32/+48
| | | | | | In the rather gnarly filterImports code, someone had forgotten the AvailTC invariant: in AvailTC n [n,s1,s2], the 'n' is itself included in the list of names.
* Instead of tracking Origin in LHsBindsLR, track it in MatchGroupDr. ERDI Gergo2014-04-132-16/+15
|
* Small issue with signatures in a TH splice (fixes Trac #8932)Simon Peyton Jones2014-04-071-2/+10
|