| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This extends D1585 with proper support for infix duplicate record
fields. In particular, it is now possible to declare record fields as
infix in a module for which `DuplicateRecordFields` is enabled, fixity
is looked up correctly and a readable (although unpleasant) error
message is generated if multiple fields with different fixities are in
scope.
As a bonus, `DEPRECATED` and `WARNING` pragmas now work for
duplicate record fields. The pragma applies to all fields with the
given label.
In addition, a couple of minor `DuplicateRecordFields` bugs, which were
pinpointed by the `T11167_ambig` test case, are fixed by this patch:
- Ambiguous infix fields can now be disambiguated by putting a type
signature on the first argument
- Polymorphic type constructor signatures (such as `ContT () IO a` in
`T11167_ambig`) now work for disambiguation
Parts of this patch are from D1585 authored by @KaneTW.
Test Plan: New tests added.
Reviewers: KaneTW, bgamari, austin
Reviewed By: bgamari
Subscribers: thomie, hvr
Differential Revision: https://phabricator.haskell.org/D1600
GHC Trac Issues: #11167, #11173
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: simonpj, austin, bgamari
Reviewed By: simonpj
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1587
GHC Trac Issues: #11164
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary: Before, `PatSyn`s were getting added twice to `tcg_patsyns` so
when inspecting afterwards there were duplicates in the list.
This makes sure that only they only get added once.
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1597
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The main issue concerned things like
data T a = MkT a deriving( C Int )
which is supposed to generate
instance C Int (T a) where {}
But the 'Int' argument (called cls_tys in the code) wasn't
even being passed to inferConstraints and mk_data_eqn, so it
really had no chance. DeriveAnyClass came along after this
code was written!
Anyway I did quite a bit of tidying up in inferConstraints.
Also I discovered that this case was not covered at all
data T a b = MkT a b deriving( Bifunctor )
What constraints should we generate for the instance context?
We can deal with classes whose last arg has kind *, like Eq, Ord;
or (* -> *), like Functor, Traversable. But we really don't have
a story for classes whose last arg has kind (* -> * -> *).
So I augmented checkSideConditions to check for that and give
a sensible error message.
ToDo: update the user manual.
|
|
|
|
| |
Differential Revision: https://phabricator.haskell.org/D1591
|
| |
|
|
|
|
| |
See Trac #11176
|
| |
|
| |
|
|
|
|
|
|
| |
This is a fixup to fd3b845c01aa26b6e5cd12c00af59e5468e21b1b
which didn't take into account 09333313f32be975faf9158fcd3648489d78ad82
having pushed as well.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Ideally, we'd have the more general
instance (MonadTrans t, Monad m, HasDynFlags m) => HasDynFlags (t m) where
getDynFlags = lift getDynFlags
definition. However, that one would overlap with the `HasDynFlags (GhcT m)`
instance. Instead we define instances for a couple of common Monad
transformers explicitly in order to avoid nasty overlapping instances.
This is a preparatory refactoring for #10874
Reviewed By: austin
Differential Revision: https://phabricator.haskell.org/D1581
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is just a trivial renaming that implements a ToDo mentioned in a comment
in Type.hs.
Adding Simon as reviewer since he added the ToDo comment.
Reviewers: simonpj, austin, goldfire, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1584
|
|
|
|
|
|
|
|
|
| |
The now removed `MaybeT` type was originally added back in 2008
via bc845b714132a897032502536fea8cd018ce325b
Reviewed By: bgamari
Differential Revision: https://phabricator.haskell.org/D1583
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Checking for missing signatures before renaming the export list is
prone to errors, so we now perform the check in `reportUnusedNames` at
which point everything has been renamed.
Test Plan: validate, new test case is T10908
Reviewers: goldfire, simonpj, austin, bgamari
Subscribers: thomie
Projects: #ghc
Differential Revision: https://phabricator.haskell.org/D1561
GHC Trac Issues: #10908
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The ConDecl type in HsDecls is an uneasy compromise. For the most part,
HsSyn directly reflects the syntax written by the programmer; and that
gives just the right "pegs" on which to hang Alan's API annotations. But
ConDecl doesn't properly reflect the syntax of Haskell-98 and GADT-style
data type declarations.
To be concrete, here's a draft new data type
```lang=hs
data ConDecl name
| ConDeclGADT
{ con_names :: [Located name]
, con_type :: LHsSigType name -- The type after the ‘::’
, con_doc :: Maybe LHsDocString }
| ConDeclH98
{ con_name :: Located name
, con_qvars :: Maybe (LHsQTyVars name)
-- User-written forall (if any), and its implicit
-- kind variables
-- Non-Nothing needs -XExistentialQuantification
, con_cxt :: Maybe (LHsContext name)
-- ^ User-written context (if any)
, con_details :: HsConDeclDetails name
-- ^ Arguments
, con_doc :: Maybe LHsDocString
-- ^ A possible Haddock comment.
} deriving (Typeable)
```
Note that
For GADTs, just keep a type. That's what the user writes.
NB:HsType can represent records on the LHS of an arrow:
{ x:Int,y:Bool} -> T
con_qvars and con_cxt are both Maybe because they are both
optional (the forall and the context of an existential data type
For ConDeclGADT the type variables of the data type do not scope
over the con_type; whereas for ConDeclH98 they do scope over con_cxt
and con_details.
Updates haddock submodule.
Test Plan: ./validate
Reviewers: simonpj, erikd, hvr, goldfire, austin, bgamari
Subscribers: erikd, goldfire, thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D1558
GHC Trac Issues: #11028
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Test Plan: Validate.
Reviewers: simonpj, goldfire, hvr, dreixel, kosmikus, austin, bgamari
Reviewed By: kosmikus, austin, bgamari
Subscribers: RyanGlScott, Fuuzetsu, bgamari, thomie, carter, dreixel
Differential Revision: https://phabricator.haskell.org/D493
GHC Trac Issues: #9766
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: austin, thomie, bgamari
Reviewed By: thomie, bgamari
Subscribers: mpickering, thomie
Differential Revision: https://phabricator.haskell.org/D1518
GHC Trac Issues: #9015
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Whenever a data instance is exported, the corresponding data family
is exported, too. This allows one to write
```
-- Foo.hs
module Foo where
data family T a
-- Bar.hs
module Bar where
import Foo
data instance T Int = MkT
-- Baz.hs
module Baz where
import Bar (T(MkT))
```
In previous versions of GHC, this required a workaround
explicit export list in `Bar`.
Reviewers: bgamari, goldfire, austin
Reviewed By: bgamari, goldfire
Subscribers: goldfire, thomie
Differential Revision: https://phabricator.haskell.org/D1573
GHC Trac Issues: #11164
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is similiar to the `-fwarn-noncanonical-monad-instances` warning
implemented via #11128, but applies to `Semigroup`/`Monoid` instead
and the `(<>)`/`mappend` methods (of which `mappend` is planned to move
out of `Monoid` at some point in the future being redundant and thus
error-prone).
This warning is contained in `-Wcompat` but not in `-Wall`.
This addresses #11150
Reviewed By: quchen
Differential Revision: https://phabricator.haskell.org/D1553
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1563
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Trac #11144 showed that we need to tidy the type in the error message
generated in TcValidity.checkUserTypeError.
This is still unsatisfactory. checkValidType was originally supposed
to be called only on types gotten directly from user-written HsTypes.
So its error messages do no tidying. But TcBinds calls it checkValidType
on an /inferred/ type, which may need tidying.
Still this at least fixes the bad error message in CustomTypeErrors02,
which was the original ticket.
Some other small refactorings:
* Remove unused Kind result of getUserTypeErrorMsg
* Rename isUserErrorTy --> userTypeError_maybe
|
|
|
|
|
| |
* Remove unused Kind result of getUserTypeErrorMsg
* Rename isUserErrorTy --> userTypeError_maybe
|
|
|
|
|
|
|
|
|
|
|
|
| |
This terrible and long-standing bug was shown up by Trac #11148.
We are trying to eta-reduce a data family instance, so that we
can then derive Functor or Generic. But we were assuming, for
absolutely not reason whatsoever, that the type variables were
lined up in a convenient order. The fact that it ever worked
was a fluke.
This patch fixes it properly. Main change is in eta_reduce
in TcInstDcls.tcDataFamInstDecl
|
|
|
|
| |
Just for debugging
|
| |
|
|
|
|
|
|
| |
This fixes Trac #11016
See Note [Add deriveds for signature contexts] in TcSimplify]
|
|
|
|
|
|
|
|
|
|
| |
As you'll see from Trac #11155, the code generator was confused
by a binding let x = y in .... Why did that happen? Because of
a (case y of {}) expression on the RHS.
The right thing is just to expand what a "trivial" expression is.
See Note [Empty case is trivial] in CoreUtils.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a non-determinism bug where where depending on the
order of uniques allocated, the specialized workers would have different
order of arguments.
Compare:
```
$s$wgo_s1CN :: Int# -> Int -> Int#
[LclId, Arity=2, Str=DmdType <L,U><L,U>]
$s$wgo_s1CN =
\ (sc_s1CI :: Int#) (sc_s1CJ :: Int) ->
case tagToEnum# @ Bool (<=# sc_s1CI 0#) of _ [Occ=Dead] {
False ->
$wgo_s1BU (Just @ Int (I# (-# sc_s1CI 1#))) (Just @ Int sc_s1CJ);
True -> 0#
}
```
vs
```
$s$wgo_s18mTj :: Int -> Int# -> Int#
[LclId, Arity=2, Str=DmdType <L,U><L,U>]
$s$wgo_s18mTj =
\ (sc_s18mTn :: Int) (sc_s18mTo :: Int#) ->
case tagToEnum# @ Bool (<=# sc_s18mTo 0#) of _ [Occ=Dead] {
False ->
$wgo_s18mUc
(Just @ Int (I# (-# sc_s18mTo 1#))) (Just @ Int sc_s18mTn);
True -> 0#
}
```
Test Plan:
I've added a new testcase
./validate
Reviewers: simonmar, simonpj, austin, goldfire, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1508
GHC Trac Issues: #4012
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Two changes:
1. Instead of generating constraints of the form (x ~ e) (as we do in
the paper), generate constraints of the form (e ~ e). The term oracle
(`tmOracle` in deSugar/TmOracle.hs) is not really efficient and in the
presence of many (x ~ e) constraints behaves quadratically. For
literals, constraints of the form (False ~ (x ~ lit)) are pretty common,
so if we start with { y ~ False, y ~ (x ~ lit) } we end up givng to the
solver (a) twice as many constraints as we need and (b) half of them
trigger the solver's weakness. This fixes #11160.
2. Treat two overloaded literals that look different as different. This
is not entirely correct but it is what both the previous and the current
check did. I had the ambitious plan to do the *right thing* (equality
between overloaded literals is undecidable in the general case) and just
use this assumption when issuing the warnings. It seems to generate much
more constraints than I expected (breaks #11161) so I just do it
immediately now instead of generating everything and filtering
afterwards.
Even if it is not (strictly speaking) correct, we have the following:
* Gives the "expected" warnings (the ones Ocaml or the previous
algorithm would give) and,
* Most importantly, it is safe. Unless a catch-all clause exists, a
match against literals is always non-exhaustive. So, effectively
this affects only what is shown to the user (and, evidently,
performance!).
|
|
|
|
|
| |
George's new exhaustiveness checker now realizes these are impossible.
Yay!
|
|
|
|
| |
Sadly we can't annotate the elements of a tuple
|
|
|
|
|
| |
This reverts commit 8cba907ad404ba4005558b5a8966390159938172 which
broke `-ddump-to-file`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adresses several problems concerned with exhaustiveness and
redundancy checking of pattern matching. The list of improvements includes:
* Making the check type-aware (handles GADTs, Type Families, DataKinds, etc.).
This fixes #4139, #3927, #8970 and other related tickets.
* Making the check laziness-aware. Cases that are overlapped but affect
evaluation are issued now with "Patterns have inaccessible right hand side".
Additionally, "Patterns are overlapped" is now replaced by "Patterns are
redundant".
* Improved messages for literals. This addresses tickets #5724, #2204, etc.
* Improved reasoning concerning cases where simple and overloaded
patterns are matched (See #322).
* Substantially improved reasoning for pattern guards. Addresses #3078.
* OverloadedLists extension does not break exhaustiveness checking anymore
(addresses #9951). Note that in general this cannot be handled but if we know
that an argument has type '[a]', we treat it as a list since, the instance of
'IsList' gives the identity for both 'fromList' and 'toList'. If the type is
not clear or is not the list type, then the check cannot do much still. I am
a bit concerned about OverlappingInstances though, since one may override the
'[a]' instance with e.g. an '[Int]' instance that is not the identity.
* Improved reasoning for nested pattern matching (partial solution). Now we
propagate type and (some) term constraints deeper when checking, so we can
detect more inconsistencies. For example, this is needed for #4139.
I am still not satisfied with several things but I would like to address at
least the following before the next release:
Term constraints are too many and not printed for non-exhaustive matches
(with the exception of literals). This sometimes results in two identical (in
appearance) uncovered warnings. Unless we actually show their difference, I
would like to have a single warning.
|
|
|
|
| |
This is a pretty commonly needed module; Haddocks are worth the effort.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch creates empty dump file when GHC was run with
`-ddump-rule-firings` (or `-ddump-rule-rewrites`) and `-ddump-to-file`
specified, and there were no rules applied. If dump already exists it
will be overwritten by empty one.
Test Plan: ./validate
Reviewers: austin, thomie, bgamari
Reviewed By: thomie, bgamari
Subscribers: thomie
Projects: #ghc
Differential Revision: https://phabricator.haskell.org/D1514
GHC Trac Issues: #10320
|
|
|
|
|
|
|
|
|
|
|
|
| |
HsImpExp.ieName is partial and fails when given e.g. `module X`
solution: use ieNames instead which returns a list of names instead of a single name.
Reviewed By: bgamari, austin
Differential Revision: https://phabricator.haskell.org/D1551
GHC Trac Issues: #11077
|
|
|
|
|
|
| |
Reviewed By: bgamari, austin
Differential Revision: https://phabricator.haskell.org/D1552
|
|
|
|
|
|
| |
Reviewed By: bgamari, austin
Differential Revision: https://phabricator.haskell.org/D1560
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I will need them for the future determinism fixes.
Test Plan: ./validate
Reviewers: simonpj, goldfire, bgamari, austin, hvr, simonmar
Reviewed By: simonpj, simonmar
Subscribers: osa1, thomie
Differential Revision: https://phabricator.haskell.org/D1537
GHC Trac Issues: #4012
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This normalizes the order of written fixities by sorting by
`OccName` making it independent of `Unique` order.
Test Plan: I've added a new testcase
Reviewers: austin, bgamari, simonmar
Reviewed By: simonmar
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1557
GHC Trac Issues: #4012
|