summaryrefslogtreecommitdiff
path: root/compiler/GHC/Rename
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Change representation of field selector occurencesShayne Fletcher2021-05-237-71/+36
| | | | | | | | | | | | - Change the names of the fields in in `data FieldOcc` - Renames `HsRecFld` to `HsRecSel` - Replace `AmbiguousFieldOcc p` in `HsRecSel` with `FieldOcc p` - Contains a haddock submodule update The primary motivation of this change is to remove `AmbiguousFieldOcc`. This is one of a suite of changes improving how record syntax (most notably record update syntax) is represented in the AST.
* Remove Maybe from Context in HsQualTyAlan Zimmerman2021-05-212-26/+26
| | | | | | Updates haddock submodule Closes #19845
* Only suggest names that make sense (#19843)Jakob Brünker2021-05-216-81/+225
| | | | | | | | | | | | | | | | * Don't show suggestions for similar variables when a data constructor in a pattern is not in scope. * Only suggest record fields when a record field for record creation or updating is not in scope. * Suggest similar record fields when a record field is not in scope with -XOverloadedRecordDot. * Show suggestions for data constructors if a type constructor or type is not in scope, but only if -XDataKinds is enabled. Fixes #19843.
* Changes to HsRecField'Shayne Fletcher2021-05-192-36/+38
|
* EPA: Remove duplicate annotations from HsDataDefnAlan Zimmerman2021-05-191-1/+1
| | | | | | | | They are repeated in the surrounding DataDecl and FamEqn. Updates haddock submodule Closes #19834
* Remove transitive information about modules and packages from interface filesMatthew Pickering2021-05-192-33/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit modifies interface files so that *only* direct information about modules and packages is stored in the interface file. * Only direct module and direct package dependencies are stored in the interface files. * Trusted packages are now stored separately as they need to be checked transitively. * hs-boot files below the compiled module in the home module are stored so that eps_is_boot can be calculated in one-shot mode without loading all interface files in the home package. * The transitive closure of signatures is stored separately This is important for two reasons * Less recompilation is needed, as motivated by #16885, a lot of redundant compilation was triggered when adding new imports deep in the module tree as all the parent interface files had to be redundantly updated. * Checking an interface file is cheaper because you don't have to perform a transitive traversal to check the dependencies are up-to-date. In the code, places where we would have used the transitive closure, we instead compute the necessary transitive closure. The closure is not computed very often, was already happening in checkDependencies, and was already happening in getLinkDeps. Fixes #16885 ------------------------- Metric Decrease: MultiLayerModules T13701 T13719 -------------------------
* Add some TcRn diagnostic messagesAlfredo Di Napoli2021-05-193-38/+7
| | | | | | | | | | | | | | | | | This commit converts some TcRn diagnostic into proper structured errors. Ported by this commit: * Add TcRnImplicitLift This commit adds the TcRnImplicitLift diagnostic message and a prototype API to be able to log messages which requires additional err info. * Add TcRnUnusedPatternBinds * Add TcRnDodgyExports * Add TcRnDodgyImports message * Add TcRnMissingImportList
* Remove useless {-# LANGUAGE CPP #-} pragmasSylvain Henry2021-05-127-7/+6
|
* Fully remove HsVersions.hSylvain Henry2021-05-127-15/+1
| | | | | | | | | | Replace uses of WARN macro with calls to: warnPprTrace :: Bool -> SDoc -> a -> a Remove the now unused HsVersions.h Bump haddock submodule
* Replace CPP assertions with Haskell functionsSylvain Henry2021-05-126-23/+27
| | | | | | | | | | | | | | | There is no reason to use CPP. __LINE__ and __FILE__ macros are now better replaced with GHC's CallStack. As a bonus, assert error messages now contain more information (function name, column). Here is the mapping table (HasCallStack omitted): * ASSERT: assert :: Bool -> a -> a * MASSERT: massert :: Bool -> m () * ASSERTM: assertM :: m Bool -> m () * ASSERT2: assertPpr :: Bool -> SDoc -> a -> a * MASSERT2: massertPpr :: Bool -> SDoc -> m () * ASSERTM2: assertPprM :: m Bool -> SDoc -> m ()
* More specific error messages for annotations (fixes #19740)Jaro Reinders2021-05-053-11/+13
|
* Improve hs-boot binds error (#19781)sheaf2021-05-032-10/+25
|
* Replace (ptext .. sLit) with `text`Sylvain Henry2021-04-296-17/+15
| | | | | | | | | | | | | | | 1. `text` is as efficient as `ptext . sLit` thanks to the rewrite rules 2. `text` is visually nicer than `ptext . sLit` 3. `ptext . sLit` encourages using one `ptext` for several `sLit` as in: ptext $ case xy of ... -> sLit ... ... -> sLit ... which may allocate SDoc's TextBeside constructors at runtime instead of sharing them into CAFs.
* Propagate free variables in extract_lctxt correctlyRyan Scott2021-04-291-1/+1
| | | | | This fixes an oversight in the implementation of `extract_lctxt` which was introduced in commit ce85cffc. Fixes #19759.
* EPA: cleanups after the mergeAlan Zimmerman2021-04-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove EpaAnn type synonym, rename EpaAnn' to EpaAnn. Closes #19705 Updates haddock submodule -- Change data EpaAnchor = AR RealSrcSpan | AD DeltaPos To instead be data EpaAnchor = AnchorReal RealSrcSpan | AnchorDelta DeltaPos Closes #19699 -- Change data DeltaPos = DP { deltaLine :: !Int, deltaColumn :: !Int } To instead be data DeltaPos = SameLine { deltaColumn :: !Int } | DifferentLine { deltaLine :: !Int, startColumn :: !Int } Closes #19698 -- Also some clean-ups of unused parts of check-exact.
* Fix #19649 by using filterInScopeM in rnFamEqnRyan Scott2021-04-082-5/+18
| | | | | | | | | | Previously, associated type family instances would incorrectly claim to implicitly quantify over type variables bound by the instance head in the `HsOuterImplicit`s that `rnFamEqn` returned. This is fixed by using `filterInScopeM` to filter out any type variables that the instance head binds. Fixes #19649.
* Introduce SevIgnore Severity to suppress warningsAlfredo Di Napoli2021-04-055-26/+19
| | | | | | | | | | | | | | | | | | | | | | This commit introduces a new `Severity` type constructor called `SevIgnore`, which can be used to classify diagnostic messages which are not meant to be displayed to the user, for example suppressed warnings. This extra constructor allows us to get rid of a bunch of redundant checks when emitting diagnostics, typically in the form of the pattern: ``` when (optM Opt_XXX) $ addDiagnosticTc (WarningWithFlag Opt_XXX) ... ``` Fair warning! Not all checks should be omitted/skipped, as evaluating some data structures used to produce a diagnostic might still be expensive (e.g. zonking, etc). Therefore, a case-by-case analysis must be conducted when deciding if a check can be removed or not. Last but not least, we remove the unnecessary `CmdLine.WarnReason` type, which is now redundant with `DiagnosticReason`.