summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc
Commit message (Collapse)AuthorAgeFilesLines
...
* Modify InlineSpec data constructor (helps fix #18138)Alina Banerjee2021-08-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The inl_inline field of the InlinePragma record is modified to store pragma source text by adding a data constructor of type SourceText. This can help in tracking the actual text of pragma names. Add/modify functions, modify type instance for InlineSpec type Modify parser, lexer to handle InlineSpec constructors containing SourceText Modify functions with InlineSpec type Extract pragma source from InlineSpec for SpecSig, InlineSig types Modify cvtInline function to add SourceText to InlineSpec type Extract name for InlineSig, SpecSig from pragma, SpectInstSig from source (fixes #18138) Extract pragma name for SpecPrag pragma, SpecSig signature Add Haddock annotation for inlinePragmaName function Add Haddock annotations for using helper functions in hsSigDoc Remove redundant ppr in pragma name for SpecSig, InlineSig; update comment Rename test to T18138 for misplaced SPECIALIZE pragma testcase
* Refactor HsStmtContext and remove HsDoRnArtyom Kuznetsov2021-08-102-11/+10
| | | | | | | | | 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.
* Add a Typeable constraint to fromStaticPtr, addressing #19729David Simmons-Duffin2021-08-101-5/+2
|
* Use Reductions to keep track of rewritingssheaf2021-08-049-365/+347
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We define Reduction = Reduction Coercion !Type. A reduction of the form 'Reduction co new_ty' witnesses an equality ty ~co~> new_ty. That is, the rewriting happens left-to-right: the right-hand-side type of the coercion is the rewritten type, and the left-hand-side type the original type. Sticking to this convention makes the codebase more consistent, helping to avoid certain applications of SymCo. This replaces the parts of the codebase which represented reductions as pairs, (Coercion,Type) or (Type,Coercion). Reduction being strict in the Type argument improves performance in some programs that rewrite many type families (such as T9872). Fixes #20161 ------------------------- Metric Decrease: T5321Fun T9872a T9872b T9872c T9872d -------------------------
* Make HsWrapper a MonoidJohn Ericson2021-08-041-0/+21
| | | | See instance documentation for caviat.
* Disable -fdefer-type-errors for linear types (#20083)Krzysztof Gogolewski2021-08-042-2/+31
|
* Catch type-checker exceptions when splicingSimon Peyton Jones2021-08-021-4/+10
| | | | | | | | In GHC.Tc.Gen.Splice.tcTopSpliceExpr we were forgetting to catch exceptions. As a result we missed the kind error in the unsolved constraints. This patch has an easy fix, which cures #20179
* Reject pattern synonyms with linear types (#18806)Krzysztof Gogolewski2021-07-293-3/+23
|
* Fix type check error message grammar (fixes #20122)CarrieMY2021-07-281-2/+2
| | | | Remove trailing spaces
* Inline less logging codeSimon Peyton Jones2021-07-281-23/+35
| | | | | | | | | | | | When eyeballing calls of GHC.Core.Opt.Simplify.Monad.traceSmpl, I saw that lots of cold-path logging code was getting inlined into the main Simplifier module. So in GHC.Utils.Logger I added a NOINLINE on logDumpFile'. For logging, the "hot" path, up to and including the conditional, should be inlined, but after that we should inline as little as possible, to reduce code size in the caller.
* Eta expand through CallStacksSimon Peyton Jones2021-07-271-22/+1
| | | | | | | This patch fixes #20103, by treating HasCallStack constraints as cheap when eta-expanding. See Note [Eta expanding through CallStacks] in GHC.Core.Opt.Arity
* Make CallStacks work better with RebindableSyntaxSimon Peyton Jones2021-07-276-40/+106
| | | | | | | | | | | | | | | | | | | | As #19918 pointed out, the CallStack mechanism didn't work well with RebindableSyntax. This patch improves matters. See GHC.Tc.Types.Evidence Note [Overview of implicit CallStacks] * New predicate isPushCallStackOrigin distinguishes when a CallStack constraint should be solved "directly" or by pushing an item on the stack. * The constructor EvCsPushCall now has a FastString, which can describe not only a function call site, but also things like "the literal 42" or "an if-then-else expression". * I also fixed #20126 thus: exprCtOrigin (HsIf {}) = IfThenElseOrigin (Previously it was "can't happen".)
* Fix a few retainer leaks of TcGblEnvMatthew Pickering2021-07-232-3/+14
| | | | | | | | | | | | 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.
* Introduce FinderLocations for decoupling Finder from DynFlagsFendor2021-07-233-4/+12
|
* Refactor SuggestExtension constructor in GhcHintAlfredo Di Napoli2021-07-211-3/+3
| | | | | | | | | | | | | | | | | | This commit refactors the SuggestExtension type constructor of the GhcHint to be more powerful and flexible. In particular, we can now embed extra user information (essentially "sugar") to help clarifying the suggestion. This makes the following possible: Suggested fix: Perhaps you intended to use GADTs or a similar language extension to enable syntax: data T where We can still give to IDEs and tools a `LangExt.Extension` they can use, but in the pretty-printed message we can tell the user a bit more on why such extension is needed. On top of that, we now have the ability to express conjuctions and disjunctons, for those cases where GHC suggests to enable "X or Y" and for the cases where we need "X and Y".
* Make TmpFs independent of DynFlagsSylvain Henry2021-07-191-1/+1
| | | | | | | | | This is small step towards #19877. We want to make the Loader/Linker interface more abstract to be easily reused (i.e. don't pass it DynFlags) but the system linker uses TmpFs which required a DynFlags value to get its temp directory. We explicitly pass the temp directory now. Similarly TmpFs was consulting the DynFlags to decide whether to clean or: this is now done by the caller in the driver code.
* Rename RecordPuns to NamedFieldPuns in LangExt.ExtensionAlfredo Di Napoli2021-07-191-1/+1
| | | | | | | | | | 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 Word64#/Int64# primopsSylvain Henry2021-07-151-1/+21
| | | | | | | | | | | | | | | | | | | | | | | Word64#/Int64# are only used on 32-bit architectures. Before this patch, operations on these types were directly using the FFI. Now we use real primops that are then lowered into ccalls. The advantage of doing this is that we can now perform constant folding on Word64#/Int64# (#19024). Most of this work was done by John Ericson in !3658. However this patch doesn't go as far as e.g. changing Word64 to always be using Word64#. Noticeable performance improvements T9203(normal) run/alloc 89870808.0 66662456.0 -25.8% GOOD haddock.Cabal(normal) run/alloc 14215777340.8 12780374172.0 -10.1% GOOD haddock.base(normal) run/alloc 15420020877.6 13643834480.0 -11.5% GOOD Metric Decrease: T9203 haddock.Cabal haddock.base
* Don't panic on 'no skolem info' and add failing testswip/no-skolem-panicZubin Duggal2021-07-131-3/+13
|
* Add TcRnIllegalWildcardsInConstructor to TcRnMessageAlfredo Di Napoli2021-07-092-0/+17
|
* Add TcRnCharLiteralOutOfRange to TcRnMessageAlfredo Di Napoli2021-07-092-0/+17
|
* Add TcRnIllegalViewPattern to TcRnMessageAlfredo Di Napoli2021-07-092-0/+20
|
* Add TcRnDuplicateFieldName to TcRnMessageAlfredo Di Napoli2021-07-092-6/+30
|
* Add TcRnIllegalWildCardsInRecord to TcRnMessageAlfredo Di Napoli2021-07-092-0/+31
|
* Add TcRnIllegalFieldPunning to TcRnMessageAlfredo Di Napoli2021-07-092-0/+21
|
* Add TcRnEmptyRecordUpdate to TcRnMessageAlfredo Di Napoli2021-07-092-0/+17
|
* Add TcRnIllegalPatSynDecl to TcRnMessageAlfredo Di Napoli2021-07-092-0/+22
|
* Add TcRnSimplifierTooManyIterations to TcRnMessageAlfredo Di Napoli2021-07-093-6/+26
|
* Add the TcRnDuplicateWarningDecls to TcRnMessageAlfredo Di Napoli2021-07-092-0/+19
|
* Add the TcRnShadowedName constructor to TcRnMessageAlfredo Di Napoli2021-07-092-1/+43
| | | | | This commit adds the TcRnShadowedName to the TcRnMessage type and it uses it in GHC.Rename.Utils.
* Dynflags: introduce DiagOptsSylvain Henry2021-07-014-38/+47
| | | | | | | | | | | | | | | | | | | | | | Use DiagOpts for diagnostic options instead of directly querying DynFlags (#17957). Surprising performance improvements on CI: T4801(normal) ghc/alloc 313236344.0 306515216.0 -2.1% GOOD T9961(normal) ghc/alloc 384502736.0 380584384.0 -1.0% GOOD ManyAlternatives(normal) ghc/alloc 797356128.0 786644928.0 -1.3% ManyConstructors(normal) ghc/alloc 4389732432.0 4317740880.0 -1.6% T783(normal) ghc/alloc 408142680.0 402812176.0 -1.3% Metric Decrease: T4801 T9961 T783 ManyAlternatives ManyConstructors Bump haddock submodule
* Remove useless .hs-bootSylvain Henry2021-07-011-1/+0
|
* Make withException use SDocContext instead of DynFlagsSylvain Henry2021-07-012-6/+8
|
* Use HsExpansion for overloaded list patternssheaf2021-06-293-47/+59
| | | | Fixes #14380, #19997
* Try to simplify zoo of functions in `Tc.Utils.Monad`Alfredo Di Napoli2021-06-2835-556/+878
| | | | | | | | | | | 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.
* Tc: Allow Typeable in quantified constraintsJakob Brünker2021-06-271-0/+1
| | | | | | | | | Previously, when using Typeable in a quantified constraint, GHC would complain that user-specified instances of Typeable aren't allowed. This was because checking for SigmaCtxt was missing from a check for whether an instance head is a hand-written binding. Fixes #20033
* Suggest similar names when reporting types in terms (#19978)Vladislav Zavialov2021-06-251-25/+33
| | | | This fixes an error message regression.
* Fixes around incomplete guards (#20023, #20024)Krzysztof Gogolewski2021-06-242-13/+6
| | | | | | | | | | - Fix linearity error with incomplete MultiWayIf (#20023) - Fix partial pattern binding error message (#20024) - Remove obsolete test LinearPolyTest It tested the special typing rule for ($), which was removed during the implementation of Quick Look 97cff9190d3. - Fix ticket numbers in linear/*/all.T, they referred to linear types issue tracker
* Fix typo in Note [Quick Look for particular Ids]Viktor Dukhovni2021-06-231-1/+1
| | | | Fixes #20029
* Converts diagnostics for two errors in Ghc.Tc.Module (#19926)Aaron Allen2021-06-233-7/+25
| | | | | | | | This adds constructors to TcRnMessage to replace use of TcRnUnknownMessage in Ghc.Tc.Module. Adds a test case for the UnsafeDueToPlugin warning. Closes #19926
* Typos, minor comment fixesKrzysztof Gogolewski2021-06-221-1/+1
| | | | | | | | | | | | | | | | | | | - Remove fstName, sndName, fstIdKey, sndIdKey - no longer used, removed from basicKnownKeyNames - Remove breakpointId, breakpointCondId, opaqueTyCon, unknownTyCon - they were used in the old implementation of the GHCi debugger - Fix typos in comments - Remove outdated comment in Lint.hs - Use 'LitRubbish' instead of 'RubbishLit' for consistency - Remove comment about subkinding - superseded by Note [Kind Constraint and kind Type] - Mention ticket ID in a linear types error message - Fix formatting in using-warnings.rst and linear-types.rst - Remove comment about 'Any' in Dynamic.hs - Dynamic now uses Typeable + existential instead of Any - Remove codeGen/should_compile/T13233.hs This was added by accident, it is not used and T13233 is already in should_fail
* Put tracing functions into their own moduleSylvain Henry2021-06-223-28/+37
| | | | | | | | 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.
* Fix error message for record updates, #19972Krzysztof Gogolewski2021-06-161-1/+1
| | | | Fix found by Adam Gundry.
* HsUniToken and HsToken for HsArrow (#19623)Vladislav Zavialov2021-06-162-5/+5
| | | | | | Another step towards a simpler design for exact printing. Updates the haddock submodule.
* Reword: representation instead of levitysheaf2021-06-1011-27/+29
| | | | fixes #19756, updates haddock submodule
* Introduce `hsExprType :: HsExpr GhcTc -> Type` in the new modulewip/hsExprTypeRyan Scott2021-06-087-86/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | `GHC.Hs.Syn.Type` The existing `hsPatType`, `hsLPatType` and `hsLitType` functions have also been moved to this module This is a less ambitious take on the same problem that !2182 and !3866 attempt to solve. Rather than have the `hsExprType` function attempt to efficiently compute the `Type` of every subexpression in an `HsExpr`, this simply computes the overall `Type` of a single `HsExpr`. - Explicitly forbids the `SplicePat` `HsIPVar`, `HsBracket`, `HsRnBracketOut` and `HsTcBracketOut` constructors during the typechecking phase by using `Void` as the TTG extension field - Also introduces `dataConCantHappen` as a domain specific alternative to `absurd` to handle cases where the TTG extension points forbid a constructor. - Turns HIE file generation into a pure function that doesn't need access to the `DsM` monad to compute types, but uses `hsExprType` instead. - Computes a few more types during HIE file generation - Makes GHCi's `:set +c` command also use `hsExprType` instead of going through the desugarer to compute types. Updates haddock submodule Co-authored-by: Zubin Duggal <zubin.duggal@gmail.com>
* Make Logger independent of DynFlagsSylvain Henry2021-06-076-46/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix #19682 by breaking cycles in DerivedsRichard Eisenberg2021-06-0510-569/+824
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit expands the old Note [Type variable cycles in Givens] to apply as well to Deriveds. See the Note for details and examples. This fixes a regression introduced by my earlier commit that killed off the flattener in favor of the rewriter. A few other things happened along the way: * unifyTest was renamed to touchabilityTest, because that's what it does. * isInsolubleOccursCheck was folded into checkTypeEq, which does much of the same work. To get this to work out, though, we need to keep more careful track of what errors we spot in checkTypeEq, and so CheckTyEqResult has become rather more glorious. * A redundant Note or two was eliminated. * Kill off occCheckForErrors; due to Note [Rewriting synonyms], the extra occCheckExpand here is always redundant. * Store blocked equalities separately from other inerts; less stuff to look through when kicking out. Close #19682. test case: typecheck/should_compile/T19682{,b}
* Port HsToCore messages to new infrastructureAlfredo Di Napoli2021-06-036-30/+104
| | | | | | | | | | | This commit converts a bunch of HsToCore (Ds) messages to use the new GHC's diagnostic message infrastructure. In particular the DsMessage type has been expanded with a lot of type constructors, each encapsulating a particular error and warning emitted during desugaring. Due to the fact that levity polymorphism checking can happen both at the Ds and at the TcRn level, a new `TcLevityCheckDsMessage` constructor has been added to the `TcRnMessage` type.
* Driver Rework PatchMatthew Pickering2021-06-032-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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