[Git][ghc/ghc][wip/backports] 8 commits: rts/CNF: Fix fixup comparison function

Ben Gamari gitlab at gitlab.haskell.org
Sat May 30 15:11:01 UTC 2020



Ben Gamari pushed to branch wip/backports at Glasgow Haskell Compiler / GHC


Commits:
8ec9a77d by Ben Gamari at 2020-05-30T10:31:04-04:00
rts/CNF: Fix fixup comparison function

Previously we would implicitly convert the difference between two words
to an int, resulting in an integer overflow on 64-bit machines.

Fixes #16992

(cherry picked from commit cf4f1e2f78840d25b132de55bce1e02256334ace)

- - - - -
90aa3c33 by Ryan Scott at 2020-05-30T10:33:49-04:00
Make boxed 1-tuples have known keys

Unlike other tuples, which use special syntax and are "known" by way
of a special `isBuiltInOcc_maybe` code path, boxed 1-tuples do not
use special syntax. Therefore, in order to make sure that the
internals of GHC are aware of the `data Unit a = Unit a` definition
in `GHC.Tuple`, we give `Unit` known keys. For the full details, see
`Note [One-tuples] (Wrinkle: Make boxed one-tuple names have known keys)`
in `GHC.Builtin.Types`.

Fixes #18097.

(cherry picked from commit 518a63d4d7e31e49a81ad66d5e5ccb1f790f6de9)

- - - - -
2436537a by Ryan Scott at 2020-05-30T10:38:12-04:00
Create di_scoped_tvs for associated data family instances properly

See `Note [Associated data family instances and di_scoped_tvs]` in
`GHC.Tc.TyCl.Instance`, which explains all of the moving parts.

Fixes #18055.

(cherry picked from commit cd8409c26d4370bf2cdcd76801974e99a9adf7b0)

- - - - -
3c82e336 by Sebastian Graf at 2020-05-30T10:44:29-04:00
PmCheck: Adjust recursion depth for inhabitation test

In #17977, we ran into the reduction depth limit of the typechecker.
That was only a symptom of a much broader issue: The recursion depth
of the coverage checker for trying to instantiate strict fields in the
`nonVoid` test was far too high (100, the `defaultMaxTcBound`).

As a result, we were performing quite poorly on `T17977`.
Short of a proper termination analysis to prove emptyness of a type,
we just arbitrarily default to a much lower recursion limit of 3.

Fixes #17977.

(cherry picked from commit ed58d4fdcbc7b4fa8fbdf3d638a8d53c444ef4f2)

- - - - -
84a23093 by Ryan Scott at 2020-05-30T10:45:46-04:00
Run checkNewDataCon before constraint-solving newtype constructors

Within `checkValidDataCon`, we used to run `checkValidType` on the
argument types of a newtype constructor before running
`checkNewDataCon`, which ensures that the user does not attempt
non-sensical things such as newtypes with multiple arguments or
constraints. This works out in most situations, but this falls over
on a corner case revealed in #17955:

```hs
newtype T = Coercible () T => T ()
```

`checkValidType`, among other things, peforms an ambiguity check on
the context of a data constructor, and that it turn invokes the
constraint solver. It turns out that there is a special case in the
constraint solver for representational equalities (read: `Coercible`
constraints) that causes newtypes to be unwrapped (see
`Note [Unwrap newtypes first]` in `TcCanonical`). This special case
does not know how to cope with an ill formed newtype like `T`, so
it ends up panicking.

The solution is surprisingly simple: just invoke `checkNewDataCon`
before `checkValidType` to ensure that the illicit newtype
constructor context is detected before the constraint solver can
run amok with it.

Fixes #17955.

(cherry picked from commit a0d8e92e9c9b67426aa139d6bc46363d8940f992)

- - - - -
3e31aad8 by Simon Peyton Jones at 2020-05-30T10:46:54-04:00
Improve skolemisation

This patch avoids skolemiseUnboundMetaTyVar making
up a fresh Name when it doesn't need to.

See Note [Skolemising and identity]

Improves error messsages for partial type signatures.

(cherry picked from commit d7002bccd7d131f8ee9b1ddcd83d62262622294d)

- - - - -
3c0e6d70 by Simon Peyton Jones at 2020-05-30T10:47:03-04:00
Improve pretty-printing for TyConBinders

In particular, show their kinds.

(cherry picked from commit fa37940cd72f82abc460f5c0a5de64dd75cee6ae)

- - - - -
99e643ba by Simon Peyton Jones at 2020-05-30T11:10:33-04:00
Fix scoping of TyCon binders in TcTyClsDecls

This patch fixes #17566 by refactoring the way we decide the final
identity of the tyvars in the TyCons of a possibly-recursive nest
of type and class decls, possibly with associated types.

It's all laid out in
  Note [Swizzling the tyvars before generaliseTcTyCon]

Main changes:

* We have to generalise each decl (with its associated types)
  all at once: TcTyClsDecls.generaliseTyClDecl

* The main new work is done in TcTyClsDecls.swizzleTcTyConBndrs

* The mysterious TcHsSyn.zonkRecTyVarBndrs dies altogether

Other smaller things:

* A little refactoring, moving bindTyClTyVars from tcTyClDecl1
  to tcDataDefn, tcSynRhs, etc.  Clearer, reduces the number of
  parameters

* Reduce the amount of swizzling required.
  Specifically, bindExplicitTKBndrs_Q_Tv doesn't need
    to clone a new Name for the TyVarTv, and not
    cloning means that in the vasly common case,
    swizzleTyConBndrs is a no-op

  In detail:
    Rename newTyVarTyVar --> cloneTyVarTyVar
    Add newTyVarTyTyVar that doesn't clone
    Use the non-cloning newTyVarTyVar in
       bindExplicitTKBndrs_Q_Tv
       Rename newFlexiKindedTyVarTyVar
           --> cloneFlexiKindedTyVarTyVar

* Define new utility function and use it
     HsDecls.familyDeclName ::
        FamilyDecl (GhcPass p) -> IdP (GhcPass p)

Updates haddock submodule.

(cherry picked from commit b9605396f1f1560aea94792646b835cadcb49f45)

- - - - -


30 changed files:

- compiler/GHC/Hs/Decls.hs
- compiler/GHC/HsToCore/PmCheck/Oracle.hs
- compiler/prelude/PrelInfo.hs
- compiler/prelude/PrelNames.hs
- compiler/prelude/TysWiredIn.hs
- compiler/typecheck/TcHsSyn.hs
- compiler/typecheck/TcHsType.hs
- compiler/typecheck/TcInstDcls.hs
- compiler/typecheck/TcMType.hs
- compiler/typecheck/TcTyClsDecls.hs
- compiler/types/TyCon.hs
- + libraries/ghc-compact/tests/T16992.hs
- + libraries/ghc-compact/tests/T16992.stdout
- libraries/ghc-compact/tests/all.T
- rts/sm/CNF.c
- + testsuite/tests/deriving/should_compile/T18055.hs
- testsuite/tests/deriving/should_compile/all.T
- testsuite/tests/partial-sigs/should_compile/ExprSigLocal.stderr
- testsuite/tests/partial-sigs/should_compile/SplicesUsed.stderr
- testsuite/tests/partial-sigs/should_compile/T10519.stderr
- testsuite/tests/partial-sigs/should_compile/T12844.stderr
- testsuite/tests/partial-sigs/should_compile/T13482.stderr
- testsuite/tests/partial-sigs/should_compile/T14217.stderr
- testsuite/tests/partial-sigs/should_compile/T14715.stderr
- testsuite/tests/partial-sigs/should_compile/T15039a.stderr
- testsuite/tests/partial-sigs/should_compile/T15039c.stderr
- testsuite/tests/partial-sigs/should_compile/T16728.stderr
- testsuite/tests/partial-sigs/should_compile/T16728b.stderr
- testsuite/tests/partial-sigs/should_fail/ExtraConstraintsWildcardNotEnabled.stderr
- testsuite/tests/partial-sigs/should_fail/InstantiatedNamedWildcardsInConstraints.stderr


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8bb8ef56f69e89eacfd94f3b7e870d7ccc8dee7f...99e643baf247fa5276ab4199cfd5a18e4c1d76d2

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/8bb8ef56f69e89eacfd94f3b7e870d7ccc8dee7f...99e643baf247fa5276ab4199cfd5a18e4c1d76d2
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200530/9ab895c9/attachment.html>


More information about the ghc-commits mailing list