summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
...
* DynFlags: refactor DmdAnalSylvain Henry2020-10-122-52/+57
| | | | Make demand analysis usable without having to provide DynFlags.
* Fall back to types when looking up data constructors (#18740)wip/ghc-18740-lookup-updateDaniel Rogozin2020-10-115-15/+104
| | | | | | | | | | | | | | | | | | | | Before this patch, referring to a data constructor in a term-level context led to a scoping error: ghci> id Int <interactive>:1:4: error: Data constructor not in scope: Int After this patch, the renamer falls back to the type namespace and successfully finds the Int. It is then rejected in the type checker with a more useful error message: <interactive>:1:4: error: • Illegal term-level use of the type constructor ‘Int’ imported from ‘Prelude’ (and originally defined in ‘GHC.Types’) • In the first argument of ‘id’, namely ‘Int’ In the expression: id Int We also do this for type variables.
* Linear types: fix quantification in GADTs (#18790)Krzysztof Gogolewski2020-10-102-3/+9
|
* Lint the compiler for extraneous LANGUAGE pragmasHécate2020-10-10143-778/+747
|
* Move File Target parser to library #18596Fendor2020-10-091-2/+86
|
* Cache HomeUnit in HscEnv (#17957)Sylvain Henry2020-10-0929-186/+191
| | | | | Instead of recreating the HomeUnit from the DynFlags every time we need it, we store it in the HscEnv.
* Add -pgmlm and -optlm flagsKrzysztof Gogolewski2020-10-091-0/+4
| | | | | !3798 added documentation and semantics for the flags, but not parsing.
* Add TyCon Set/Env and use them in a few places.Andreas Klebinger2020-10-0916-108/+356
| | | | | | | | | | | Firstly this improves code clarity. But it also has performance benefits as we no longer go through the name of the TyCon to get at it's unique. In order to make this work the recursion check for TyCon has been moved into it's own module in order to avoid import cycles.
* Fix desugaring of record updates on data familiesSimon Peyton Jones2020-10-096-36/+122
| | | | | | | | | | | | This fixes a long-standing bug in the desugaring of record updates for data families, when the latter involves a GADT. It's all explained in Note [Update for GADTs] in GHC.HsToCore.Expr. Building the correct cast is surprisingly tricky, as that Note explains. Fixes #18809. The test case (in indexed-types/should_compile/T18809) contains several examples that exercise the dark corners.
* Linear types: fix roles in GADTs (#18799)Krzysztof Gogolewski2020-10-091-2/+2
|
* ApiAnnotations : preserve parens in GADTsAlan Zimmerman2020-10-095-53/+65
| | | | | | | | | A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT.
* Bignum: match on small Integer/NaturalSylvain Henry2020-10-091-3/+14
| | | | | | | | | Previously we only matched on *variables* whose unfoldings were a ConApp of the form `IS lit#` or `NS lit##`. But we forgot to match on the ConApp directly... As a consequence, constant folding only worked after the FloatOut pass which creates bindings for most sub-expressions. With this patch, matching on bignums works even with -O0 (see bignumMatch test).
* Add a flag to indicate that gcc supports -no-pieKrzysztof Gogolewski2020-10-091-0/+2
| | | | Fixes #17919.
* Expose RTS-only ways (#18651)Sylvain Henry2020-10-094-25/+87
| | | | | Some RTS ways are exposed via settings (ghcThreaded, ghcDebugged) but not all. It's simpler if the RTS exposes them all itself.
* rts: fix race condition in StgCRunTamar Christina2020-10-091-2/+3
| | | | | | | | | | | | | | | | On windows the stack has to be allocated 4k at a time, otherwise we get a segfault. This is done by using a helper ___chkstk_ms that is provided by libgcc. The Haskell side already knows how to handle this but we need to do the same from STG. Previously we would drop the stack in StgRun but would only make it valid whenever the scheduler loop ran. This approach was fundamentally broken in that it falls apart when you take a signal from the OS. We see it less often because you initially get allocated a 1MB stack block which you have to blow past first. Concretely this means we must always keep the stack valid. Fixes #18601.
* Use UnitId in the backend instead of UnitSylvain Henry2020-10-092-7/+8
| | | | | | In Cmm we can only have real units identified with an UnitId. Other units (on-the-fly instantiated units and holes) are only used in type-checking backpack sessions that don't produce Cmm.
* Misc cleanupKrzysztof Gogolewski2020-10-079-24/+18
| | | | | | | | | | | * Include funTyCon in exposedPrimTyCons. Every single place using exposedPrimTyCons was adding funTyCon manually. * Remove unused synTyConResKind and ieLWrappedName * Add recordSelectorTyCon_maybe * In exprType, panic instead of giving a trace message and dummy output. This prevents #18767 reoccurring. * Fix compilation error in fragile concprog001 test (part of #18732)
* Preserve as-parsed arrow type for HsUnrestrictedArrowAlan Zimmerman2020-10-072-11/+19
| | | | | | | | | | When linear types are disabled, HsUnrestrictedArrow is treated as HslinearArrow. Move this adjustment into the type checking phase, so that the parsed source accurately represents the source as parsed. Closes #18791
* Apply suggestion to compiler/GHC/SysTools.hsSylvain Henry2020-10-071-1/+1
|
* Fix -flink-rts (#18651)Sylvain Henry2020-10-071-21/+29
| | | | | Before this patch -flink-rts could link with GHC's rts instead of the selected one.
* WinIO: Small changes related to atomic request swaps.Andreas Klebinger2020-10-073-2/+30
| | | | | | | | | | | | Move the atomix exchange over the Ptr type to an internal module. Fix a bug caused by us passing ptr-to-ptr instead of ptr to atomic exchange. Renamed interlockedExchange to exchangePtr. I've also added an cas primitive. It turned out we don't need it for WinIO but I'm leaving it in as it's useful for other things.
* Fix linear types in TH splices (#18465)Krzysztof Gogolewski2020-10-051-1/+4
|
* Inline `integerDecodeDouble#` and constant-fold `decodeDouble_Int64#` insteadSebastian Graf2020-10-052-50/+50
| | | | | | | | | | | | | | | | | | | | | | | | Currently, `integerDecodeDouble#` is known-key so that it can be recognised in constant folding. But that is very brittle and doesn't survive worker/wrapper, which we even do for `NOINLINE` things since #13143. Also it is a trade-off: The implementation of `integerDecodeDouble#` allocates an `Integer` box that never cancels aways if we don't inline it. Hence we recognise the `decodeDouble_Int64#` primop instead in constant folding, so that we can inline `integerDecodeDouble#`. As a result, `integerDecodeDouble#` no longer needs to be known-key. While doing so, I realised that we don't constant-fold `decodeFloat_Int#` either, so I also added a RULE for it. `integerDecodeDouble` is dead, so I deleted it. Part of #18092. This improves the 32-bit `realToFrac`/`toRational`: Metric Decrease: T10359
* Reject linearity in kinds in checkValidType (#18780)Krzysztof Gogolewski2020-10-022-12/+29
| | | | Patch taken from https://gitlab.haskell.org/ghc/ghc/-/issues/18624#note_300673
* Minor TTG clean-up: comments, unused families, bottomVladislav Zavialov2020-10-022-52/+54
| | | | | | 1. Fix and update section headers in GHC/Hs/Extension.hs 2. Delete the unused 'XCoreAnn' and 'XTickPragma' families 3. Avoid calls to 'panic' in 'pprStmt'
* Fix typos in commentsKrzysztof Gogolewski2020-10-0222-24/+24
| | | | [skip ci]
* Refactor: remove rnHsDocVladislav Zavialov2020-10-015-82/+13
| | | | It did not do any useful work.
* Fix pretty-printing of the mult-polymorphic arrowVladislav Zavialov2020-10-011-1/+1
| | | | A follow-up to !4020 (5830a12c46e7227c276a8a71213057595ee4fc04)
* Don't attach CPR signatures to NOINLINE data structures (#18154)Sebastian Graf2020-10-011-83/+115
| | | | | | | | | | | | | | | | | Because the generated `KindRep`s don't have an unfolding, !3230 did not actually stop to compute, attach and serialise unnecessary CPR signatures for them. As already said in `Note [CPR for data structures]`, that leads to bloated interface files which is ultimately quadratic for Nested CPR. So we don't attach any CPR signature to bindings that * Are not thunks (because thunks are not in WHNF) * Have arity 0 (which means the top-level constructor is not a lambda) If the data structure has an unfolding, we continue to look through it. If not (as is the case for `KindRep`s), we look at the unchanged CPR signature and see `topCprType`, as expected.
* Don't import GHC.Unit to reduce the number of dependenciesSylvain Henry2020-10-0110-10/+19
|
* Parser: remove some unused importsSylvain Henry2020-10-011-15/+9
| | | | These are not reported by GHC because Happy adds {-# OPTIONS_GHC -w #-}
* Less DynFlags in Header parsingSylvain Henry2020-10-016-18/+22
|
* Use ADTs for parser errors/warningsSylvain Henry2020-10-0122-649/+1446
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Haskell and Cmm parsers/lexers now report errors and warnings using ADTs defined in GHC.Parser.Errors. They can be printed using functions in GHC.Parser.Errors.Ppr. Some of the errors provide hints with a separate ADT (e.g. to suggest to turn on some extension). For now, however, hints are not consistent across all messages. For example some errors contain the hints in the main message. I didn't want to change any message with this patch. I expect these changes to be discussed and implemented later. Surprisingly, this patch enhances performance. On CI (x86_64/deb9/hadrian, ghc/alloc): parsing001 -11.5% T13719 -2.7% MultiLayerModules -3.5% Naperian -3.1% Bump haddock submodule Metric Decrease: MultiLayerModules Naperian T13719 parsing001
* Remove mAIN completelyFendor2020-10-012-4/+2
|
* Use HomeUnit for main module without module declarationFendor2020-10-011-1/+1
|
* Add mainModuleNameIs and demote mainModIsFendor2020-10-012-7/+10
| | | | | | Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from.
* Pmc: Don't call exprType on type arguments (#18767)Sebastian Graf2020-09-301-1/+2
| | | | Fixes #18767.
* Omit redundant kind equality check in solverRichard Eisenberg2020-09-301-13/+21
| | | | | | | See updated Note [Use loose types in inert set] in GHC.Tc.Solver.Monad. Close #18753.
* Remove unsafeGlobalDynFlags (#17957, #14597)Sylvain Henry2020-09-3012-131/+164
| | | | | There are still global variables but only 3 booleans instead of a single DynFlags.
* Bump Cabal, hsc2hs, directory, process submodulesBen Gamari2020-09-301-1/+1
| | | | Necessary for recent Win32 bump.
* PmCheck: Long-distance information for LocalBinds (#18626)Sebastian Graf2020-09-304-26/+125
| | | | | | | | | | | | | | | | | | | | | | Now `desugarLocalBind` (formerly `desugarLet`) reasons about * `FunBind`s that * Have no pattern matches (so which aren't functions) * Have a singleton match group with a single GRHS * (which may have guards) * and looks through trivial post-typechecking `AbsBinds` in doing so to pick up the introduced renamings. And desugars to `PmLet` LYG-style guards. Since GRHSs are no longer denoted simply by `NonEmpty PmGRHS`, but also need to carry a `[PmGrd]` for the `PmLet`s from `LocalBind`s, I added `PmGRHSs` to capture that. Since we call out to the desugarer more often, I found that there were superfluous warnings emitted when desugaring e.g. case expressions. Thus, I made sure that we deactivate any warnings in the LYG desugaring steps by the new wrapper function `noCheckDs`. There's a regression test in `T18626`. Fixes #18626.
* Make the parser module less dependent on DynFlagsSylvain Henry2020-09-2910-81/+95
| | | | Bump haddock submodule
* Improve error messages for (a %m) without LinearTypesVladislav Zavialov2020-09-291-3/+18
| | | | | | | | Detect when the user forgets to enable the LinearTypes extension and produce a better error message. Steals the (a %m) syntax from TypeOperators, the workaround is to write (a % m) instead.
* New linear types syntax: a %p -> b (#18459)Vladislav Zavialov2020-09-2915-34/+42
| | | | | | Implements GHC Proposal #356 Updates the haddock submodule.
* Linear types: fix kind inference when checking dataconsKrzysztof Gogolewski2020-09-291-1/+3
|
* Optimize NthCo (FunCo ...) in coercion optRichard Eisenberg2020-09-293-28/+39
| | | | | | | | | | We were missing this case previously. Close #18528. Metric Decrease: T18223 T5321Fun
* Remove outdated comment in rnHsTyKiVladislav Zavialov2020-09-271-4/+0
| | | | | This comment dates back to 3df40b7b78044206bbcffe3e2c0a57d901baf5e8 and does not seem relevant anymore.
* Don't rearrange (->) in the renamerVladislav Zavialov2020-09-271-36/+26
| | | | | | | | | | The parser produces an AST where the (->) is already associated correctly: 1. (->) has the least possible precedence 2. (->) is right-associative Thus we don't need to handle it in mkHsOpTyRn.
* Comments: change outdated reference to mergeOpswip/docs-no-merge-opsVladislav Zavialov2020-09-271-1/+1
| | | | | | | As of 686e06c59c3aa6b66895e8a501c7afb019b09e36, GHC.Parser.PostProcess.mergeOps no longer exists. [ci skip]
* Fix handling of function coercions (#18747)Krzysztof Gogolewski2020-09-261-1/+1
| | | | This was broken when we added multiplicity to the function type.