summaryrefslogtreecommitdiff
path: root/compiler/GHC
Commit message (Collapse)AuthorAgeFilesLines
* Refactor the constraint solver pipelinewip/T23070Simon Peyton Jones2023-03-2212-4114/+4254
| | | | | | | | | | | | | | | | The big change is to put the entire type-equality solver into GHC.Tc.Solver.Equality, rather than scattering it over Canonical and Interact. Other changes * EqCt becomes its own data type, a bit like QCInst. This is great because EqualCtList is then just [EqCt] * New module GHC.Tc.Solver.Dict has come of the class-contraint solver. In due course it will be all. One step at a time. This MR is intended to have zero change in behaviour: it is a pure refactor. It opens the way to subsequent tidying up, we believe.
* Be more careful about quantificationSimon Peyton Jones2023-03-227-160/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This MR is driven by #23051. It does several things: * It is guided by the generalisation plan described in #20686. But it is still far from a complete implementation of that plan. * Add Note [Inferred type with escaping kind] to GHC.Tc.Gen.Bind. This explains that we don't (yet, pending #20686) directly prevent generalising over escaping kinds. * In `GHC.Tc.Utils.TcMType.defaultTyVar` we default RuntimeRep and Multiplicity variables, beause we don't want to quantify over them. We want to do the same for a Concrete tyvar, but there is nothing sensible to default it to (unless it has kind RuntimeRep, in which case it'll be caught by an earlier case). So we promote instead. * Pure refactoring in GHC.Tc.Solver: * Rename decideMonoTyVars to decidePromotedTyVars, since that's what it does. * Move the actual promotion of the tyvars-to-promote from `defaultTyVarsAndSimplify` to `decidePromotedTyVars`. This is a no-op; just tidies up the code. E.g then we don't need to return the promoted tyvars from `decidePromotedTyVars`. * A little refactoring in `defaultTyVarsAndSimplify`, but no change in behaviour. * When making a TauTv unification variable into a ConcreteTv (in GHC.Tc.Utils.Concrete.makeTypeConcrete), preserve the occ-name of the type variable. This just improves error messages. * Kill off dead code: GHC.Tc.Utils.TcMType.newConcreteHole
* Compute LambdaFormInfo when using JavaScript backend.Luite Stegeman2023-03-211-3/+16
| | | | | | | | | | | CmmCgInfos is needed to write interface files, but the JavaScript backend does not generate it, causing "Name without LFInfo" warnings. This patch adds a conservative but always correct CmmCgInfos when the JavaScript backend is used. Fixes #23053
* Allow LLVM backend to use HDoc for faster file generation.Alex Mason2023-03-218-348/+524
| | | | | | Also remove the MetaStmt constructor from LlvmStatement and places the annotations into the Store statement. Includes “Implement a workaround for -no-asm-shortcutting bug“ (https://gitlab.haskell.org/ghc/ghc/-/commit/2fda9e0df886cc551e2cd6b9c2a384192bdc3045)
* Document pdep / pext primopsBodigrim2023-03-211-10/+59
|
* Add structured error messages for GHC.Tc.Utils.EnvTorsten Schmits2023-03-2114-100/+255
| | | | | | | | | Tracking ticket: #20119 MR: !10129 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`.
* Rename () into Unit, (,,...,,) into Tuple<n> (#21294)Andrei Borzenkov2023-03-216-23/+113
| | | | | | | | | | | | | | | | | | | | | This patch implements a part of GHC Proposal #475. The key change is in GHC.Tuple.Prim: - data () = () - data (a,b) = (a,b) - data (a,b,c) = (a,b,c) ... + data Unit = () + data Tuple2 a b = (a,b) + data Tuple3 a b c = (a,b,c) ... And the rest of the patch makes sure that Unit and Tuple<n> are pretty-printed as () and (,,...,,) in various contexts. Updates the haddock submodule. Co-authored-by: Vladislav Zavialov <vlad.z.4096@gmail.com>
* Add structured error messages for GHC.Tc.Utils.BackpackTorsten Schmits2023-03-175-37/+109
| | | | | | | | | | | | Tracking ticket: #20119 MR: !10127 This converts uses of `mkTcRnUnknownMessage` to newly added constructors of `TcRnMessage`. One occurrence, when handing a nested error from the interface loading machinery, was omitted. It will be handled by a subsequent changeset that addresses interface errors.
* Fix BCO creation setting caps when -j > -NTeo Camarasu2023-03-163-49/+13
| | | | | | | | | | | | | | * Remove calls to 'setNumCapabilities' in 'createBCOs' These calls exist to ensure that 'createBCOs' can benefit from parallelism. But this is not the right place to call `setNumCapabilities`. Furthermore the logic differs from that in the driver causing the capability count to be raised and lowered at each TH call if -j > -N. * Remove 'BCOOpts' No longer needed as it was only used to thread the job count down to `createBCOs` Resolves #23049
* Simplifier: `countValArgs` should not count Type args (#23102)Sebastian Graf2023-03-131-1/+1
| | | | | | | | | I observed miscompilations while working on !10088 caused by this. Fixes #23102. Metric Decrease: T10421
* JS: fix implementation of forceBool to use JS backend syntaxwip/js-forceBoolJosh Meredith2023-03-131-1/+1
|
* Simplify: Move `wantEtaExpansion` before expensive `do_eta_expand` checkSebastian Graf2023-03-101-5/+6
| | | | | | | | There is no need to run arity analysis and what not if we are not in a Simplifier phase that eta-expands or if we don't want to eta-expand the expression in the first place. Purely a refactoring with the goal of improving compiler perf.
* JS: Fix implementation of MK_JSVALJosh Meredith2023-03-101-2/+2
|
* DmdAnal: Fix a panic on OPAQUE and trivial/PAP RHS (#22997)Sebastian Graf2023-03-101-10/+12
| | | | | | | We should not panic in `add_demands` (now `set_lam_dmds`), because that code path is legimitely taken for OPAQUE PAP bindings, as in T22997. Fixes #22997.
* Fixes #19627.Apoorv Ingle2023-03-091-2/+2
| | | | | | | | | Previously the solver failed with an unhelpful "solver reached too may iterations" error. With the fix for #21909 in place we no longer have the possibility of generating such an error if we have `-fconstraint-solver-iteration` > `-fgivens-fuel > `-fwanteds-fuel`. This is true by default, and the said fix also gives programmers a knob to control how hard the solver should try before giving up. This commit adds: * Reference to ticket #19627 in the Note [Expanding Recursive Superclasses and ExpansionFuel] * Test `typecheck/should_fail/T19627.hs` for regression purposes
* Delete created temporary subdirectories at end of session.Luite Stegeman2023-03-092-71/+117
| | | | | | | | This patch adds temporary subdirectories to the list of paths do clean up at the end of the GHC session. This fixes warnings about non-empty temporary directories. Fixes #22952
* bytecode: Fix bitmaps for BCOs used to tag tuples and prim call argsAlexis King2023-03-082-36/+61
| | | | fixes #23068
* Constraint simplification loop now depends on `ExpansionFuel`Apoorv Ingle2023-03-067-98/+290
| | | | | | | | | | | | | | instead of a boolean flag for `CDictCan.cc_pend_sc`. Pending givens get a fuel of 3 while Wanted and quantified constraints get a fuel of 1. This helps pending given constraints to keep up with pending wanted constraints in case of `UndecidableSuperClasses` and superclass expansions while simplifying the infered type. Adds 3 dynamic flags for controlling the fuels for each type of constraints `-fgivens-expansion-fuel` for givens `-fwanteds-expansion-fuel` for wanteds and `-fqcs-expansion-fuel` for quantified constraints Fixes #21909 Added Tests T21909, T21909b Added Note [Expanding Recursive Superclasses and ExpansionFuel]
* Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115)Andrei Borzenkov2023-03-064-139/+414
| | | | | | | | | | | | | | | | | | | | | | | | | I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module module into a proper TcRnMessage. Instead, these TcRnMessage messages were introduced: TcRnIllegalInstanceHeadDecl TcRnUnexpectedStandaloneDerivingDecl TcRnUnusedVariableInRuleDecl TcRnUnexpectedStandaloneKindSig TcRnIllegalRuleLhs TcRnBadAssocRhs TcRnDuplicateRoleAnnot TcRnDuplicateKindSig TcRnIllegalDerivStrategy TcRnIllegalMultipleDerivClauses TcRnNoDerivStratSpecified TcRnStupidThetaInGadt TcRnBadImplicitSplice TcRnShadowedTyVarNameInFamResult TcRnIncorrectTyVarOnLhsOfInjCond TcRnUnknownTyVarsOnRhsOfInjCond Was introduced one helper type: RuleLhsErrReason
* Enable response files for linker if supportedGabriella Gonzalez2023-03-063-4/+7
|
* More fixes for `type data` declarationsSimon Peyton Jones2023-03-037-62/+111
| | | | | | | | | | | | | | | | | | | | | | This MR fixes #23022 and #23023. Specifically * Beef up Note [Type data declarations] in GHC.Rename.Module, to make invariant (I1) explicit, and to name the several wrinkles. And add references to these specific wrinkles. * Add a Lint check for invariant (I1) above. See GHC.Core.Lint.checkTypeDataConOcc * Disable the `caseRules` for dataToTag# for `type data` values. See Wrinkle (W2c) in the Note above. Fixes #23023. * Refine the assertion in dataConRepArgTys, so that it does not complain about the absence of a wrapper for a `type data` constructor Fixes #23022. Acked-by: Simon Peyton Jones <simon.peytonjones@gmail.com>
* Get the right in-scope set in etaBodyForJoinPointSimon Peyton Jones2023-03-021-4/+11
| | | | Fixes #23026
* ncg/aarch64: Handle MULTILINE_COMMENT identically as COMMENTsZubin Duggal2023-03-021-5/+7
| | | | | | | | Commit 7566fd9de38c67360c090f828923d41587af519c with the fix for #22798 was incomplete as it failed to handle MULTILINE_COMMENT pseudo-instructions, and didn't completly fix the compiler panics when compiling with `-fregs-graph`. Fixes #23002
* constant folding: Correct type of decodeDouble_Int64 ruleMatthew Pickering2023-03-021-5/+1
| | | | | | | | The first argument is Int64# unconditionally, so we better produce something of that type. This fixes a core lint error found in the ad package. Fixes #23019
* Check for platform support for JavaScript foreign importsLuite Stegeman2023-03-021-1/+2
| | | | | | | | | GHC was accepting `foreign import javascript` declarations on non-JavaScript platforms. This adds a check so that these are only supported on an platform that supports the JavaScript calling convention. Fixes #22774
* Don't suppress *all* WantedsRichard Eisenberg2023-03-022-17/+24
| | | | | | | | | | | | | | Code in GHC.Tc.Errors.reportWanteds suppresses a Wanted if its rewriters have unfilled coercion holes; see Note [Wanteds rewrite Wanteds] in GHC.Tc.Types.Constraint. But if we thereby suppress *all* errors that's really confusing, and as #22707 shows, GHC goes on without even realising that the program is broken. Disaster. This MR arranges to un-suppress them all if they all get suppressed. Close #22707
* fix: Consider strictness annotation in rep_bindromes2023-03-011-3/+9
| | | | Fixes #23036
* Refine the test for naughty record selectorsSimon Peyton Jones2023-03-011-36/+51
| | | | | | | The test for naughtiness in record selectors is surprisingly subtle. See the revised Note [Naughty record selectors] in GHC.Tc.TyCl.Utils. Fixes #23038.
* Account for TYPE vs CONSTRAINT in mkSelCoSimon Peyton Jones2023-02-283-7/+46
| | | | | | | As #23018 showed, in mkRuntimeRepCo we need to account for coercions between TYPE and COERCION. See Note [mkRuntimeRepCo] in GHC.Core.Coercion.
* Take more care with unlifted bindings in the specialiserSimon Peyton Jones2023-02-282-53/+89
| | | | | | | | As #22998 showed, we were floating an unlifted binding to top level, which breaks a Core invariant. The fix is easy, albeit a little bit conservative. See Note [Care with unlifted bindings] in GHC.Core.Opt.Specialise
* JS: fix for overlap with copyMutableByteArray# (#23033)Sylvain Henry2023-02-281-9/+2
| | | | | | The code wasn't taking into account some kind of overlap. cgrun070 has been extended to test the missing case.
* Account for local rules in specImportsSimon Peyton Jones2023-02-283-46/+65
| | | | | | | | | | | As #23024 showed, in GHC.Core.Opt.Specialise.specImports, we were generating specialisations (a locally-define function) for imported functions; and then generating specialisations for those locally-defined functions. The RULE for the latter should be attached to the local Id, not put in the rules-for-imported-ids set. Fix is easy; similar to what happens in GHC.HsToCore.addExportFlagsAndRules
* Don't specialise incoherent instance applicationsGergő Érdi2023-02-2720-279/+553
| | | | | | | | | | | | | | Using incoherent instances, there can be situations where two occurrences of the same overloaded function at the same type use two different instances (see #22448). For incoherently resolved instances, we must mark them with `nospec` to avoid the specialiser rewriting one to the other. This marking is done during the desugaring of the `WpEvApp` wrapper. Fixes #22448 Metric Increase: T15304
* Fix shadowing bug in prepareAltsSimon Peyton Jones2023-02-242-13/+26
| | | | | | | | As #23012 showed, GHC.Core.Opt.Simplify.Utils.prepareAlts was using an OutType to construct an InAlt. When shadowing is in play, this is outright wrong. See Note [Shadowing in prepareAlts].
* Fix ParallelListComp out of scope suggestionAaron Allen2023-02-241-7/+30
| | | | | | | | | This patch makes it so vars from one block of a parallel list comprehension are not in scope in a subsequent block during type checking. This was causing GHC to emit a faulty suggestion when an out of scope variable shared the occ name of a var from a different block. Fixes #22940
* JS: make some arithmetic primops faster (#22835)Sylvain Henry2023-02-241-2/+2
| | | | | | Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring@users.noreply.gitlab.haskell.org>
* Explicit migration timeline for loopy SC solvingsheaf2023-02-231-1/+1
| | | | | | | | | This patch updates the warning message introduced in commit 9fb4ca89bff9873e5f6a6849fa22a349c94deaae to specify an explicit migration timeline: GHC will no longer support this constraint solving mechanism starting from GHC 9.10. Fixes #22912
* fix: Update documentation linksromes2023-02-212-4/+4
| | | | | | | Closes #23008 Additionally batches some fixes to pointers to the Note [Wired-in units], and a typo in said note.
* GHC proposal 496 - Nullary record wildcardsGeorgi Lyubenov2023-02-2110-69/+213
| | | | | | | | | | | | | | | | | | | This patch implements GHC proposal 496, which allows record wildcards to be used for nullary constructors, e.g. data A = MkA1 | MkA2 { fld1 :: Int } f :: A -> Int f (MkA1 {..}) = 0 f (MkA2 {..}) = fld1 To achieve this, we add arity information to the record field environment, so that we can accept a constructor which has no fields while continuing to reject non-record constructors with more than 1 field. See Note [Nullary constructors and empty record wildcards], as well as the more general overview in Note [Local constructor info in the renamer], both in the newly introduced GHC.Types.ConInfo module. Fixes #22161
* Disallow `tagToEnum#` on `type data` typeswip/T22948Ryan Scott2023-02-205-0/+36
| | | | | We don't want to allow users to conjure up values of a `type data` type using `tagToEnum#`, as these simply don't exist at the value level.
* Treat type data declarations as empty when checking pattern-matching coverageRyan Scott2023-02-202-5/+32
| | | | | | | The data constructors for a `type data` declaration don't exist at the value level, so we don't want GHC to warn users to match on them. Fixes #22964.
* Don't generate datacon wrappers for `type data` declarationsRyan Scott2023-02-203-6/+73
| | | | | | | | | | | | | | | | | | Data constructor wrappers only make sense for _value_-level data constructors, but data constructors for `type data` declarations only exist at the _type_ level. This patch does the following: * The criteria in `GHC.Types.Id.Make.mkDataConRep` for whether a data constructor receives a wrapper now consider whether or not its parent data type was declared with `type data`, omitting a wrapper if this is the case. * Now that `type data` data constructors no longer receive wrappers, there is a spot of code in `refineDefaultAlt` that panics when it encounters a value headed by a `type data` type constructor. I've fixed this with a special case in `refineDefaultAlt` and expanded `Note [Refine DEFAULT case alternatives]` to explain why we do this. Fixes #22948.
* Handle top-level Addr# literals in the bytecode compilerAlexis King2023-02-207-143/+222
| | | | Fixes #22376.
* compiler: fix cost centre profiling breakage in wasm NCG due to incorrect ↵Cheng Shao2023-02-201-2/+1
| | | | | | | | | | | | | | | | | register mapping The wasm NCG used to map CCCS to a wasm global, based on the observation that CCCS is a transient register that's already handled by thread state load/store logic, so it doesn't need to be backed by the rCCCS field in the register table. Unfortunately, this is wrong, since even when Cmm execution hasn't yielded back to the scheduler, the Cmm code may call enterFunCCS, which does use rCCCS. This breaks cost centre profiling in a subtle way, resulting in inaccurate stack traces in some test cases. The fix is simple though: just remove the CCCS mapping.
* Improve GHC.Tc.Gen.App.tcInstFunwip/T22908Simon Peyton Jones2023-02-201-16/+12
| | | | | | | | | | | | | | It wasn't behaving right when inst_final=False, and the function had no type variables f :: Foo => Int Rather a corner case, but we might as well do it right. Fixes #22908 Unexpectedly, three test cases (all using :type in GHCi) got slightly better output as a result: T17403, T14796, T12447
* Expand synonyms in RoughMapsheaf2023-02-161-1/+5
| | | | | | | | | | | We were failing to expand type synonyms in the function GHC.Core.RoughMap.typeToRoughMatchLookupTc, even though the RoughMap infrastructure crucially relies on type synonym expansion to work. This patch adds the missing type-synonym expansion. Fixes #22985
* Narrow the dont-decompose-newtype testSimon Peyton Jones2023-02-164-166/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | Following #22924 this patch narrows the test that stops us decomposing newtypes. The key change is the use of noGivenNewtypeReprEqs in GHC.Tc.Solver.Canonical.canTyConApp. We went to and fro on the solution, as you can see in #22924. The result is carefully documented in Note [Decomoposing newtype equalities] On the way I had revert most of commit 3e827c3f74ef76d90d79ab6c4e71aa954a1a6b90 Author: Richard Eisenberg <rae@cs.brynmawr.edu> Date: Mon Dec 5 10:14:02 2022 -0500 Do newtype unwrapping in the canonicaliser and rewriter See Note [Unwrap newtypes first], which has the details. It turns out that (a) 3e827c3f makes GHC behave worse on some recursive newtypes (see one of the tests on this commit) (b) the finer-grained test (namely noGivenNewtypeReprEqs) renders 3e827c3f unnecessary
* Factor JS Rts generation for h$c{_,0,1,2} into h$c{n} and improve name cachingJosh Meredith2023-02-165-121/+107
|
* JS: disable debugging info for heap objectsSylvain Henry2023-02-161-1/+3
|
* Add -single-threaded flag to force single threaded rtsOleg Grenrus2023-02-151-3/+4
| | | | | This is the small part of implementing https://github.com/ghc-proposals/ghc-proposals/pull/240