summaryrefslogtreecommitdiff
path: root/compiler/GHC/Rename
Commit message (Collapse)AuthorAgeFilesLines
* Implement -Wforall-identifier (#20609)Vladislav Zavialov2021-11-125-8/+26
| | | | | | | | | | In accordance with GHC Proposal #281 "Visible forall in types of terms": For three releases before this change takes place, include a new warning -Wforall-identifier in -Wdefault. This warning will be triggered at definition sites (but not use sites) of forall as an identifier. Updates the haddock submodule.
* Flesh out Note [The stupid context] and reference itRyan Scott2021-11-091-1/+3
| | | | | | `Note [The stupid context]` in `GHC.Core.DataCon` talks about stupid contexts from `DatatypeContexts`, but prior to this commit, it was rather outdated. This commit spruces it up and references it from places where it is relevant.
* Fix deferOutOfScopeVariables for qualified #20472CarrieMY2021-11-051-10/+4
|
* EPA: Get rid of bare SrcSpan's in the ParsedSourceAlan Zimmerman2021-11-026-33/+35
| | | | | | | | | | | | | The ghc-exactPrint library has had to re-introduce the relatavise phase. This is needed if you change the length of an identifier and want the layout to be preserved afterwards. It is not possible to relatavise a bare SrcSpan, so introduce `SrcAnn NoEpAnns` for them instead. Updates haddock submodule.
* HsToken for let/in (#19623)Vladislav Zavialov2021-11-021-5/+5
| | | | One more step towards the new design of EPA.
* EPA: Use LocatedA for ModuleNameAlan Zimmerman2021-10-241-1/+1
| | | | | This allows us to use an Anchor with a DeltaPos in it when exact printing.
* Refactor package importsSylvain Henry2021-10-222-19/+61
| | | | | | | | | Use an (Raw)PkgQual datatype instead of `Maybe FastString` to represent package imports. Factorize the code that renames RawPkgQual into PkgQual in function `rnPkgQual`. Renaming consists in checking if the FastString is the magic "this" keyword, the home-unit unit-id or something else. Bump haddock submodule
* Make fields of GlobalRdrElt strictMatthew Pickering2021-10-204-7/+11
| | | | | | | | In order to do this I thought it was prudent to change the list type to a bag type to avoid doing a lot of premature work in plusGRE because of ++. Fixes #19201
* shadowNames: Use OccEnv a, not [OccName]Joachim Breitner2021-10-151-2/+2
| | | | | | | | | | | | | | this allows us to use a smarter implementation based on `Data.IntSet.differenceWith`, which should do less work. Also, it will unblock improvements to !6703. The `OccEnv a` really denotes a set of `OccName`s. We are not using `OccSet`, though, because that is an `OccEnv OccName`, and we in !6703 we want to use this with differently-valued `OccEnv`s. But `OccSet`s are readily and safely coerced into `OccEnv`s. There is no other use of `delLocalRdrEnvList` remaining, so removing that.
* shadowNames: Accept an OccName, not a GreNameJoachim Breitner2021-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | previously, the `shadowNames` function would take `[GreName]`. This has confused me for two reasons: * Why `GreName` and not `Name`? Does the difference between a normal name and a field name matter? The code of `shadowNames` shows that it does not, but really its better if the type signatures says so. * Why `Name` and not `OccName`? The point of `shadowNames` is to shadow _unqualified names_, at least in the two use cases I am aware of (names defined on the GHCI prompt or in TH splices). The code of `shadowNames` used to have cases that peek at the module of the given name and do something if that module appears in the `GlobalRdrElt`, but I think these cases are dead code, I don’t see how they could occur in the above use cases. Also, I replaced them with `errors` and GHC would still validate. Hence removing this code (yay!) This change also allows `shadowNames` to accept an `OccSet` instead, which allows for a faster implemenation; I’ll try that separately. This in stead might help with !6703.
* Add Hint to "Empty 'do' block" Error Message#20147Carrie Xu2021-10-121-0/+3
|
* Reject GADT pattern matches in arrow notationsheaf2021-10-092-9/+12
| | | | | | | | | | | | Tickets #20469 and #20470 showed that the current implementation of arrows is not at all up to the task of supporting GADTs: GHC produces ill-scoped Core programs because it doesn't propagate the evidence introduced by a GADT pattern match. For the time being, we reject GADT pattern matches in arrow notation. Hopefully we are able to add proper support for GADTs in arrows in the future.
* compiler: occEnvElts -> nonDetOccEnvEltsBen Gamari2021-09-291-1/+1
|
* compiler: Rename nameEnvElts -> nonDetNameEnvEltsBen Gamari2021-09-291-1/+1
|
* TH stage restriction check for constructors, selectors, and class methodsAndrea Condoluci2021-09-291-3/+7
| | | | Closes ticket #17820.
* Refactor module dependencies codeSylvain Henry2021-09-171-6/+9
| | | | | | * moved deps related code into GHC.Unit.Module.Deps * refactored Deps module to not export Dependencies constructor to help maintaining invariants
* EPA: correctly capture comments between 'where' and bindsAlan Zimmerman2021-09-171-1/+1
| | | | | | | | | | | | In the following foo = x where -- do stuff doStuff = do stuff The "-- do stuff" comment is captured in the HsValBinds. Closes #20297
* ghci: Fix rec statements in interactive promptMatthew Pickering2021-08-171-9/+42
| | | | | | | | | | | | | | | | | | | | | | | | We desugar a recursive Stmt to somethign like (a,_,c) <- mfix (\(a,b,_) -> do { ... ; return (a,b,c) }) ...stuff after the rec... The knot-tied tuple must contain * All the variables that are used before they are bound in the `rec` block * All the variables that are used after the entire `rec` block In the case of GHCi, however, we don't know what variables will be used after the `rec` (#20206). For example, we might have ghci> rec { x <- e1; y <- e2 } ghci> print x ghci> print y So we have to assume that *all* the variables bound in the `rec` are used afterwards. We use `Nothing` in the argument to segmentRecStmts to signal that all the variables are used. Fixes #20206
* Refactoring module dependenciesSylvain Henry2021-08-131-4/+4
| | | | | | | | | | | | | | * Make mkDependencies pure * Use Sets instead of sorted lists Notable perf changes: MultiLayerModules(normal) ghc/alloc 4130851520.0 2981473072.0 -27.8% T13719(normal) ghc/alloc 4313296052.0 4151647512.0 -3.7% Metric Decrease: MultiLayerModules T13719
* Move `ol_witness` to `OverLitTc`Dr. ERDI Gergo2021-08-131-2/+3
| | | | | | | | We also add a new `ol_from_fun` field to renamed (but not yet typechecked) OverLits. This has the nice knock-on effect of making total some typechecker functions that used to be partial. Fixes #20151
* Refactor HsStmtContext and remove HsDoRnArtyom Kuznetsov2021-08-102-59/+48
| | | | | | | | | Parts of HsStmtContext were split into a separate data structure HsDoFlavour. Before this change HsDo used to have HsStmtContext inside, but in reality only parts of HsStmtContext were used and other cases were invariants handled with panics. Separating those parts into its own data structure helps us to get rid of those panics as well as HsDoRn type family.
* rename: Avoid unnecessary map lookupBen Gamari2021-07-271-2/+2
| | | | | | | | Previously the -Wcompat-unqualified-imports warning would first check whether an import is of a covered module, incurring an map lookup, before checking the simple boolean predicate of whether it is qualified. This is more expensive than strictly necessary (although at the moment the warning is unused, so this will make little difference).
* Remove unused module GHC.Rename.DocFendor2021-07-271-23/+0
|
* Fix a few retainer leaks of TcGblEnvMatthew Pickering2021-07-231-1/+4
| | | | | | | | | | | | Methodology: Create a -hi profile and then search for TcGblEnv then use ghc-debug to work out why they are being retained and remove the reason. Retaining TcGblEnv is dangerous because it contains pointers to things such as a TypeEnv which is updated throughout compilation. I found two places which were retaining a TcGblEnv unecessarily. Also fix a few places where an OccName was retaining an Id.
* Rename RecordPuns to NamedFieldPuns in LangExt.ExtensionAlfredo Di Napoli2021-07-193-4/+4
| | | | | | | | | | This commit renames the `RecordPuns` type constructor inside `GHC.LanguageExtensions.Type.hs` to `NamedFieldPuns`. The rationale is that the `RecordPuns` language extension was deprecated a long time ago, but it was still present in the AST, introducing an annoying mismatch between what GHC suggested (i.e. "use NamedFieldPuns") and what that translated into in terms of Haskell types.
* Add TcRnIllegalWildcardsInConstructor to TcRnMessageAlfredo Di Napoli2021-07-091-7/+1
|
* Remove redundant patSigErrAlfredo Di Napoli2021-07-091-16/+0
|
* Add TcRnCharLiteralOutOfRange to TcRnMessageAlfredo Di Napoli2021-07-091-6/+1
|
* Add TcRnIllegalViewPattern to TcRnMessageAlfredo Di Napoli2021-07-091-6/+1
|
* Add TcRnDuplicateFieldName to TcRnMessageAlfredo Di Napoli2021-07-091-10/+1
|
* Add TcRnIllegalWildCardsInRecord to TcRnMessageAlfredo Di Napoli2021-07-091-3/+6
|
* Add TcRnIllegalFieldPunning to TcRnMessageAlfredo Di Napoli2021-07-091-7/+2
|
* Add TcRnEmptyRecordUpdate to TcRnMessageAlfredo Di Napoli2021-07-091-4/+1
|
* Add TcRnIllegalPatSynDecl to TcRnMessageAlfredo Di Napoli2021-07-091-4/+1
|
* Add the TcRnDuplicateWarningDecls to TcRnMessageAlfredo Di Napoli2021-07-091-8/+1
|
* Add the TcRnShadowedName constructor to TcRnMessageAlfredo Di Napoli2021-07-091-15/+3
| | | | | This commit adds the TcRnShadowedName to the TcRnMessage type and it uses it in GHC.Rename.Utils.
* Remove useless .hs-bootSylvain Henry2021-07-011-1/+0
|
* Use HsExpansion for overloaded list patternssheaf2021-06-293-38/+179
| | | | Fixes #14380, #19997
* Try to simplify zoo of functions in `Tc.Utils.Monad`Alfredo Di Napoli2021-06-2810-229/+361
| | | | | | | | | | | This commit tries to untangle the zoo of diagnostic-related functions in `Tc.Utils.Monad` so that we can have the interfaces mentions only `TcRnMessage`s while we push the creation of these messages upstream. It also ports TcRnMessage diagnostics to use the new API, in particular this commit switch to use TcRnMessage in the external interfaces of the diagnostic functions, and port the old SDoc to be wrapped into TcRnUnknownMessage.
* driver: Add implicit package dependencies for template-haskell packageMatthew Pickering2021-06-251-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | When TemplateHaskellQuotes is enabled, we also generate programs which mention symbols from the template-haskell module. So that package is added conditionally if the extension is turned on. We should really do the same for other wired-in packages: * base * ghc-bignum * ghc-prim * rts When we link an executable, we must also link against these libraries. In accordance with every other package, these dependencies should be added into the direct dependencies for a module automatically and end up in the interface file to record the fact the object file was created by linking against these packages. Unfortunately it is not so easy to work out when symbols from each of these libraries ends up in the generated program. You might think that `base` would always be used but the `ghc-prim` package doesn't depend on `base`, so you have to be a bit careful and this futher enhancement is left to a future patch.
* Put tracing functions into their own moduleSylvain Henry2021-06-221-0/+1
| | | | | | | | Now that Outputable is independent of DynFlags, we can put tracing functions using SDocs into their own module that doesn't transitively depend on any GHC.Driver.* module. A few modules needed to be moved to avoid loops in DEBUG mode.
* Do not reassociate lexical negation (#19838)Vladislav Zavialov2021-06-192-8/+15
|
* HsUniToken and HsToken for HsArrow (#19623)Vladislav Zavialov2021-06-163-10/+11
| | | | | | Another step towards a simpler design for exact printing. Updates the haddock submodule.
* Reword: representation instead of levitysheaf2021-06-101-4/+4
| | | | fixes #19756, updates haddock submodule
* Make Logger independent of DynFlagsSylvain Henry2021-06-071-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce LogFlags as a independent subset of DynFlags used for logging. As a consequence in many places we don't have to pass both Logger and DynFlags anymore. The main reason for this refactoring is that I want to refactor the systools interfaces: for now many systools functions use DynFlags both to use the Logger and to fetch their parameters (e.g. ldInputs for the linker). I'm interested in refactoring the way they fetch their parameters (i.e. use dedicated XxxOpts data types instead of DynFlags) for #19877. But if I did this refactoring before refactoring the Logger, we would have duplicate parameters (e.g. ldInputs from DynFlags and linkerInputs from LinkerOpts). Hence this patch first. Some flags don't really belong to LogFlags because they are subsystem specific (e.g. most DumpFlags). For example -ddump-asm should better be passed in NCGConfig somehow. This patch doesn't fix this tight coupling: the dump flags are part of the UI but they are passed all the way down for example to infer the file name for the dumps. Because LogFlags are a subset of the DynFlags, we must update the former when the latter changes (not so often). As a consequence we now use accessors to read/write DynFlags in HscEnv instead of using `hsc_dflags` directly. In the process I've also made some subsystems less dependent on DynFlags: - CmmToAsm: by passing some missing flags via NCGConfig (see new fields in GHC.CmmToAsm.Config) - Core.Opt.*: - by passing -dinline-check value into UnfoldingOpts - by fixing some Core passes interfaces (e.g. CallArity, FloatIn) that took DynFlags argument for no good reason. - as a side-effect GHC.Core.Opt.Pipeline.doCorePass is much less convoluted.
* Driver Rework PatchMatthew Pickering2021-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch comprises of four different but closely related ideas. The net result is fixing a large number of open issues with the driver whilst making it simpler to understand. 1. Use the hash of the source file to determine whether the source file has changed or not. This makes the recompilation checking more robust to modern build systems which are liable to copy files around changing their modification times. 2. Remove the concept of a "stable module", a stable module was one where the object file was older than the source file, and all transitive dependencies were also stable. Now we don't rely on the modification time of the source file, the notion of stability is moot. 3. Fix TH/plugin recompilation after the removal of stable modules. The TH recompilation check used to rely on stable modules. Now there is a uniform and simple way, we directly track the linkables which were loaded into the interpreter whilst compiling a module. This is an over-approximation but more robust wrt package dependencies changing. 4. Fix recompilation checking for dynamic object files. Now we actually check if the dynamic object file exists when compiling with -dynamic-too Fixes #19774 #19771 #19758 #17434 #11556 #9121 #8211 #16495 #7277 #16093
* Specify the reason for import for the backpack's extra importsDivam2021-06-021-5/+5
|
* Add -Wmissing-exported-pattern-synonym-signaturesThomas Winant2021-05-291-38/+70
| | | | | | | | | | | | | After !4741, it was no longer possible to silence a warning about a missing pattern synonym signature if the `-Wmissing-signatures` flag was on. Restore the previous semantics while still adhering to the principle "enabling an additional warning flag should never make prior warnings disappear". For more symmetry and granularity, introduce `-Wmissing-exported-pattern-synonym-signatures`. See Note [Missing signatures] for an overview of all flags involved.
* Change representation of HsGetField and HsProjectionShayne Fletcher2021-05-271-8/+8
| | | | | Another change in a series improving record syntax in the AST. The key change in this commit is the renaming of `HsFieldLabel` to `DotFieldOcc`.
* HsToken for HsPar, ParPat, HsCmdPar (#19523)Vladislav Zavialov2021-05-233-25/+25
| | | | This patch is a first step towards a simpler design for exact printing.