| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch does a raft of useful tidy-ups in the type checker.
I've been meaning to do this for some time, and finally made
time to do it en route to ICFP.
1. Modify TcType.ExpType to make a distinct data type,
InferResult for the Infer case, and consequential
refactoring.
2. Define a new function TcUnify.fillInferResult, to fill in
an InferResult. It uses TcMType.promoteTcType to promote
the type to the level of the InferResult.
See TcMType Note [Promoting a type]
This refactoring is in preparation for an improvement
to typechecking pattern bindings, coming next.
I flirted with an elaborate scheme to give better
higher rank inference, but it was just too complicated.
See TcMType Note [Promotion and higher rank types]
3. Add to InferResult a new field ir_inst :: Bool to say
whether or not the type used to fill in the
InferResult should be deeply instantiated. See
TcUnify Note [Deep instantiation of InferResult].
4. Add a TcLevel to SkolemTvs. This will be useful generally
- it's a fast way to see if the type
variable escapes when floating (not used yet)
- it provides a good consistency check when updating a
unification variable (TcMType.writeMetaTyVarRef, the
level_check_ok check)
I originally had another reason (related to the flirting
in (2), but I left it in because it seems like a step in
the right direction.
5. Reduce and simplify the plethora of uExpType,
tcSubType and related functions in TcUnify. It was
such an opaque mess and it's still not great, but it's
better.
6. Simplify the uo_expected field of TypeEqOrigin. Richard
had generatlised it to a ExpType, but it was almost always
a Check type. Now it's back to being a plain TcType which
is much, much easier.
7. Improve error messages by refraining from skolemisation when
it's clear that there's an error: see
TcUnify Note [Don't skolemise unnecessarily]
8. Type.isPiTy and isForAllTy seem to be missing a coreView check,
so I added it
9. Kill off tcs_used_tcvs. Its purpose is to track the
givens used by wanted constraints. For dictionaries etc
we do that via the free vars of the /bindings/ in the
implication constraint ic_binds. But for coercions we
just do update-in-place in the type, rather than
generating a binding. So we need something analogous to
bindings, to track what coercions we have added.
That was the purpose of tcs_used_tcvs. But it only
worked for a /single/ iteration, whereas we may have
multiple iterations of solving an implication. Look
at (the old) 'setImplicationStatus'. If the constraint
is unsolved, it just drops the used_tvs on the floor.
If it becomes solved next time round, we'll pick up
coercions used in that round, but ignore ones used in
the first round.
There was an outright bug. Result = (potentialy) bogus
unused-constraint errors. Constructing a case where this
actually happens seems quite trick so I did not do so.
Solution: expand EvBindsVar to include the (free vars of
the) coercions, so that the coercions are tracked in
essentially the same way as the bindings.
This turned out to be much simpler. Less code, more
correct.
10. Make the ic_binds field in an implication have type
ic_binds :: EvBindsVar
instead of (as previously)
ic_binds :: Maybe EvBindsVar
This is notably simpler, and faster to use -- less
testing of the Maybe. But in the occaional situation
where we don't have anywhere to put the bindings, the
belt-and-braces error check is lost. So I put it back
as an ASSERT in 'setImplicationStatus' (see the use of
'termEvidenceAllowed')
All these changes led to quite bit of error message wibbling
|
|
|
|
|
|
| |
This is now working apparently. It relates to when a
polymorphic function gets instantiated, under some
implicit paramter bindings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch fixes a regression introduced, post 8.0.1, by
this major commit:
commit 15b9bf4ba4ab47e6809bf2b3b36ec16e502aea72
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date: Sat Jun 11 23:49:27 2016 +0100
Improve typechecking of let-bindings
This major commit was initially triggered by #11339, but it
spiraled into a major review of the way in which type
signatures for bindings are handled, especially partial type
signatures.
I didn't get the typechecking of pattern bindings right, leading
to Trac #12427.
In fixing this I found that this program doesn't work:
data T where
T :: a -> ((forall b. [b]->[b]) -> Int) -> T
h1 y = case y of T _ v -> v
Works in 7.10, but not in 8.0.1.
There's a happy ending. I found a way to fix this, and improve
pattern bindings too. Not only does this fix #12427, but it also
allows
In particular,we now can accept
data T where MkT :: a -> Int -> T
... let { MkT _ q = t } in ...
Previously this elicited "my head exploded" but it's really
fine since q::Int.
The approach is described in detail in TcBinds
Note [Typechecking pattern bindings]
Super cool. And not even a big patch!
|
|
|
|
| |
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Test Plan: validate
Reviewers: goldfire, simonpj, austin, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2595
GHC Trac Issues: #12679
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
In the old implementation of hsig files, we directly
reused the implementation of abstract data types from
hs-boot files. However, this was WRONG. Consider the
following program (an abridged version of bkpfail24):
{-# LANGUAGE GADTs #-}
unit p where
signature H1 where
data T
signature H2 where
data T
module M where
import qualified H1
import qualified H2
f :: H1.T ~ H2.T => a -> b
f x = x
Prior to this patch, M was accepted, because the type
inference engine concluded that H1.T ~ H2.T does not
hold (indeed, *presently*, it does not). However, if
we subsequently instantiate p with the same module for
H1 and H2, H1.T ~ H2.T does hold! Unsound.
The key is that abstract types from signatures need to
be treated like *skolem variables*, since you can interpret
a Backpack unit as a record which is universally quantified
over all of its abstract types, as such (with some fake
syntax for structural records):
p :: forall t1 t2. { f :: t1 ~ t2 => a -> b }
p = { f = \x -> x } -- ill-typed
Clearly t1 ~ t2 is not solvable inside p, and also clearly
it could be true at some point in the future, so we better
not treat the lambda expression after f as inaccessible.
The fix seems to be simple: do NOT eagerly fail when trying
to simplify the given constraints. Instead, treat H1.T ~ H2.T
as an irreducible constraint (rather than an insoluble
one); this causes GHC to treat f as accessible--now we will
typecheck the rest of the function (and correctly fail).
Per the OutsideIn(X) paper, it's always sound to fail less
when simplifying givens.
We do NOT apply this fix to hs-boot files, where abstract
data is also guaranteed to be nominally distinct (since
it can't be implemented via a reexport or a type synonym.)
This is a somewhat unnatural state of affairs (there's
no way to really interpret this in Haskell land) but
no reason to change behavior.
I deleted "representationally distinct abstract data",
which is never used anywhere in GHC.
In the process of constructing this fix, I also realized
our implementation of type synonym matching against abstract
data was not sufficiently restrictive. In order for
a type synonym T to be well-formed type, it must be a
nullary synonym (i.e., type T :: * -> *, not type T a = ...).
Furthermore, since we use abstract data when defining
instances, they must not have any type family applications.
More details in #12680. This probably deserves some sort
of short paper report.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: goldfire, simonpj, austin, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2594
|
|
|
|
|
|
|
|
|
| |
Newtypes cannot (currently) have an unboxed argument type.
But Trac #12729 showed that this was only being checked for
newtypes in H98 syntax; in GADT snytax they were let through.
This patch moves the test to checkValidDataCon, where it properly
belongs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously we pruned out orphan modules from external packages but this
was wrong. Fixes #12733 (which has more discussion.)
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, bgamari, austin
Reviewed By: simonpj
Subscribers: simonpj, thomie
Differential Revision: https://phabricator.haskell.org/D2610
GHC Trac Issues: #12733
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
I also added some more comments about the orphan and family instance
hashing business.
Fixes #12723.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: bgamari, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2607
GHC Trac Issues: #12723
|
|
|
|
| |
Due to #12725.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
tc266 was failing intermittently on Windows due to a very small
compile_timeout_multiplier. This test was added in
e907e1f12f4dedc0ec13c7a501c8810bcfc03583 which doesn't appear to have
any timng dependence, so I see no reason to retain the multiplier at
all.
Test Plan: Validate
Reviewers: ezyang, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2601
|
|
|
|
| |
There seems to be a runtime system bug here, as described in #12714.
|
|
|
|
|
|
|
|
| |
Strangely the allocation numbers on Windows differ significantly from
those on Linux. Usually I would just update the number, but I would
really like to understand why this is the case. This is a rather large
deviation in the compilation of a program which really shouldn't have
any appreciable platform dependence.
|
|
|
|
| |
See #12712.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
The wrappers in matchExpectedConTy were being composed back
to front, resulting in a Core Lint error. Yikes! This has
been here a long time.
Fixes Trac #12676.
|
|
|
|
|
|
|
|
|
| |
Trac #12698 exposed a nasty bug in the typechecking for
pattern synonmys: the existential type variables weren't
being put in properly-scoped order.
For some reason TcPatSyn.tcCollectEx was colleting them as a
set, not as a list! Easily fixed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
To fix this issue, we simply disable `RebindableSyntax` whenever we rename
the code generated from a deriving clause.
Fixes #12688.
Test Plan: make test TEST=T12688
Reviewers: simonpj, austin, bgamari
Reviewed By: simonpj, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2591
GHC Trac Issues: #12688
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As identified by Joachim, this test broke the Travis build. It appears
that this is due to the usage of the single-threaded runtime there. I've
confirmed that this fix causes the Travis build to pass:
https://travis-ci.org/snoyberg/ghc/builds/167368988.
Test Plan: Confirm tests now pass
Reviewers: austin, nomeata, bgamari
Reviewed By: nomeata, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2593
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Foreign imports with "prim" convention require a valid symbol identifier
(see linked issue). We check this.
Fix line too long
Test Plan: Validate
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2563
GHC Trac Issues: #12355
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, when you attempted to derive an instance for a typeclass,
e.g.,
```
class C1 (a :: Constraint) where
class C2 where
deriving instance C1 C2
```
GHC would complain that `C2`'s data constructors aren't in scope. But
that
makes no sense, since typeclasses don't have constructors! By refining
the
checks that GHC performs when deriving, we can make the error message a
little more sensible.
This also cleans up a related `DeriveAnyClass` infelicity. Before, you
wouldn't have been able to compile code like this:
```
import System.IO (Handle)
class C a
deriving instance C Handle
```
Since GHC was requiring that all data constructors of `Handle` be in
scope. But `DeriveAnyClass` doesn't even generate code that mentions
any data constructors, so this requirement is silly!
Fixes #11509.
Test Plan: make test TEST=T11509
Reviewers: simonpj, austin, bgamari
Reviewed By: simonpj, bgamari
Subscribers: thomie, simonpj
Differential Revision: https://phabricator.haskell.org/D2558
GHC Trac Issues: #11509
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously BinIface had some dedicated logic for handling tuple names in
the symbol table. As it turns out, this logic was essentially dead code
as it was superceded by the special handling of known-key things. Here
we cull the tuple code-path and use the known-key codepath for all
tuple-ish things.
This had a surprising number of knock-on effects,
* constraint tuple datacons had to be made known-key (previously they
were not)
* IfaceTopBndr was changed from being a synonym of OccName to a
synonym of Name (since we now need to be able to deserialize Names
directly from interface files)
* the change to IfaceTopBndr complicated fingerprinting, since we need
to ensure that we don't go looking for the fingerprint of the thing
we are currently fingerprinting in the fingerprint environment (see
notes in MkIface). Handling this required distinguishing between
binding and non-binding Name occurrences in the Binary serializers.
* the original name cache logic which previously lived in IfaceEnv has
been moved to a new NameCache module
* I ripped tuples and sums out of knownKeyNames since they introduce a
very large number of entries. During interface file deserialization
we use static functions (defined in the new KnownUniques module) to
map from a Unique to a known-key Name (the Unique better correspond
to a known-key name!) When we need to do an original name cache
lookup we rely on the parser implemented in isBuiltInOcc_maybe.
* HscMain.allKnownKeyNames was folded into PrelInfo.knownKeyNames.
* Lots of comments were sprinkled about describing the new scheme.
Updates haddock submodule.
Test Plan: Validate
Reviewers: niteria, simonpj, austin, hvr
Reviewed By: simonpj
Subscribers: simonmar, niteria, thomie
Differential Revision: https://phabricator.haskell.org/D2467
GHC Trac Issues: #12532, #12415
|
|
|
|
| |
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
|
|
|
|
|
|
|
|
|
|
|
| |
This patch builds on the one for Trac #12124, by dealing properly
with out-of-scope "hole" errors.
This fixes Trac #12529. The hard error coming from visible type application
is still there, but the out-of-scope error is no longer suppressed.
(Arguably the VTA message should be suppressed somehow, but that's a
battle for another day.)
|
|
|
|
|
| |
Commit f352e5cd7bb629fe0ca3b913bfbe7bee43d62f3a fixed #12456. Let's add a test
to make sure it stays fixed.
|
|
|
|
|
| |
Commit af21e38855f7d517774542b360178b05045ecb08 fixed #12598. Let's add a test
to make sure it stays fixed.
|
|
|
|
|
| |
The fix for #12584 also fixed the problem in #12411. Let's add a test to ensure
that it stays fixed.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes #12584, where wildcard patterns were snuck into an
expression, which then crashed the typechecker in TcExpr since EWildPats
aren't supposed to appear in the AST after renaming.
The problem was that `rnTopSpliceDecl` failed to check for errors from
`rnSplice` (as done by other callers to `rnSplice`).
Thanks to Shayan for reporting this!
Reviewers: simonpj, austin
Reviewed By: simonpj
Subscribers: simonpj, thomie
Differential Revision: https://phabricator.haskell.org/D2539
GHC Trac Issues: #12584
|
|
|
|
|
|
|
|
| |
A rule with a phase specification trying to match on a constructor with
a wrapper will fail to match, as the wrapper will be inlined by then.
The fact that it works in the other case is also mostly by accident.
(Split into two test cases so that regressions with regard what works so
far are caught.)
|
|
|
|
|
|
|
|
|
| |
which test a few variants of rules involving constructors, including
nullary constructors, constructors with wrappers, and unsaturated of
constructors.
At the moment, all the rules work as expected, despite GHC’s compile
time warnings when called with -Wall.
|
|
|
|
| |
These ones test the variations in coment:15 of the ticket
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With my latest commits
76a5477 Move zonking out of tcFamTyPats
b255ae7 Orient improvement constraints better
perf has improved slightly for T1969:
allocs: 733M -> 26M
residency: 43M -> 41M
I don't know exactly why, but hey, it's good
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch fixes an infinite loop in the constraint solver,
shown up by Trac #12522.
The solution is /very/ simple: just reverse the orientation of the
derived constraints arising from improvement using type-family
injectivity. I'm not very proud of the fix --- it seems fragile
--- but it has the very great merit of simplicity, and it works
fine.
See Note [Improvement orientation] in TcInteract, and some
discussion on the Trac ticket.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The target of this patch is exports such as:
```
module Foo ( T(A, B, C) ) where
```
Essentially this patch makes sure that we use the correct lookup functions in order
to lookup the names in parent-children export lists. This change
highlighted the complexity of this small part of GHC which accounts for
the scale.
This change was motivated by wanting to
remove the `PatternSynonym` constructor from `Parent`. As with all these
things, it quickly spiraled out of control into a much larger refactor.
Reviewers: simonpj, goldfire, bgamari, austin
Subscribers: adamgundry, thomie
Differential Revision: https://phabricator.haskell.org/D2179
GHC Trac Issues: #11970
|
|
|
|
| |
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
|
|
|
|
| |
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
This patch implements Backpack for GHC. It's a big patch but I've tried quite
hard to keep things, by-in-large, self-contained.
The user facing specification for Backpack can be found at:
https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst
A guide to the implementation can be found at:
https://github.com/ezyang/ghc-proposals/blob/backpack-impl/proposals/0000-backpack-impl.rst
Has a submodule update for Cabal, as well as a submodule update
for filepath to handle more strict checking of cabal-version.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, austin, simonmar, bgamari, goldfire
Subscribers: thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D1482
|
|
|
|
| |
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When looking up flags, we make sure to lookup the non-deprecated flags first
by ordering the list of flags.
Reviewers: bgamari, austin, mpickering
Reviewed By: mpickering
Subscribers: mpickering, thomie
Differential Revision: https://phabricator.haskell.org/D2541
GHC Trac Issues: #12574
|
|
|
|
| |
This was (accidentally?) introduced in 465c6c5d15f8fb54afb78408f3a79e75e74d2cd4
|
|
|
|
|
| |
See Note [Constraints and errors] in TcRnMonad. This
patch fixes Trac #12124 in quite a neat way.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary:
Note that Cabal needs one more bugfix which is in PR to
fix GHC bootstrapping. But the rest of the patch is
ready for review.
Needs a filepath submodule update because cabal check
became more strict.
This patch handles the abstract-ification of Version and
PackageName.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: bgamari, austin
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2555
|
|
|
|
|
| |
Somehow this testcase works on Darwin but not on Linux. This deserves
further investigation.
|
|
|
|
|
|
| |
The output contains the pid and executable path of the bash process
which spawned the failing process. It doesn't seem worth the effort to
cleanse this output; just ignore it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It currently fails with,
=====> T6132(normal) 1 of 1 [0, 0, 0]
cd "./runghc/T6132.run" && "/Users/bgamari/ghc/inplace/test
spaces/ghc-stage2" -c T6132.hs -dcore-lint -dcmm-lint
-no-user-package-db -rtsopts -fno-warn-missed-specialisations
-fshow-warning-groups -dno-debug-output
Compile failed (exit code 1) errors were:
T6132.hs:1:2: error: parse error on input ‘#!/’
*** unexpected failure for T6132(normal)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This means that, on POSIX systems, there will be only one ghc process
used for running scripts, as opposed to the current situation of a
runghc process and a ghc process. Beyond minor performance benefits of
not having an extra fork and resident process, the more important impact
of this is automatically getting proper signal handling. I noticed this
problem myself when running runghc as PID1 inside a Docker container.
I attempted to create a shim library for executeFile that would work for
both POSIX and Windows, but unfortunately I ran into issues with exit
codes being propagated correctly (see
https://github.com/fpco/replace-process/issues/2). Therefore, this patch
leaves the Windows behavior unchanged. Given that signals are a POSIX
issue, this isn't too bad a trade-off. If someone has suggestions for
better Windows _exec support, please let me know.
Reviewers: erikd, austin, bgamari
Reviewed By: bgamari
Subscribers: Phyx, thomie
Differential Revision: https://phabricator.haskell.org/D2538
|