summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* A collection of type-inference refactorings.Simon Peyton Jones2016-10-2179-859/+1322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make TcLevel increase by 1 not 2Simon Peyton Jones2016-10-211-11/+6
| | | | | | | | | | Make the TcLevel of a flatten-meta-var be always zero. See TcType.fmvTcLevel. This allows the levels of implication constraints to to up by 1 each time instead of 2, which is less confusing. This change has no effect on type checking.
* Test Trac #12507Simon Peyton Jones2016-10-212-0/+17
| | | | | | This is now working apparently. It relates to when a polymorphic function gets instantiated, under some implicit paramter bindings.
* Comments and trivial refactoringSimon Peyton Jones2016-10-215-21/+23
|
* Refactor typechecking of pattern bindingsSimon Peyton Jones2016-10-215-177/+304
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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!
* Typos in commentsGabor Greif2016-10-214-5/+5
|
* check-cpp: Make it more robustBen Gamari2016-10-201-1/+3
| | | | Catch more than one space
* Fix Mac OS X build by removing space after ASSERT.Edward Z. Yang2016-10-201-1/+1
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Mark previously failing backpack tests as passing, with correct output.Edward Z. Yang2016-10-2011-35/+119
| | | | Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Only delete instances when merging when there is an exact match.Edward Z. Yang2016-10-203-24/+78
| | | | | | | | | | | | | | | | | | | Summary: Previously, we deleted if the heads matched, which meant that we effectively were picking an arbitrary instance if there were incompatible instances. The new behavior makes more sense, although without incoherent instances you are unlikely to be able to do anything useful with the instances. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2596
* Support constraint synonym implementations of abstract classes.Edward Z. Yang2016-10-207-1/+137
| | | | | | | | | | | | | | Summary: Test Plan: validate Reviewers: goldfire, simonpj, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2595 GHC Trac Issues: #12679
* New story for abstract data types in hsig files.Edward Z. Yang2016-10-2024-31/+401
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* configure.ac: Report Unregisterised settingErik de Castro Lopo2016-10-201-0/+1
| | | | | | | | | | | | | | | Showing the value of this configure option in the configure output can help debugging issues in build bots etc. Test Plan: N/A Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2616
* StgCmmPrim: Add missing write barrier.Peter Trommler2016-10-191-0/+4
| | | | | | | | | | | | | | | | | | | On architectures with weak memory consistency a write barrier is needed before the write to the pointer array. Fixes #12469 Test Plan: rebuilt Stackage nightly twice on powerpc64le Reviewers: hvr, rrnewton, erikd, austin, simonmar, bgamari Reviewed By: erikd, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2525 GHC Trac Issues: #12469
* Test for newtype with unboxed argumentSimon Peyton Jones2016-10-197-42/+56
| | | | | | | | | 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.
* cmm/Hoopl/Dataflow: remove unused codeMichal Terepeta2016-10-183-665/+11
| | | | | | | | | | | | | | | | | | | | We had *a lot* of code copied from Hoopl that is for rewriting. But GHC doesn't use it (it only uses some forked Hoopl code for analysis). So we can safely kill all this code and make it much easier to refactor and improve the parts that we do use. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Test Plan: ./validate Reviewers: austin, simonmar, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2612
* Compute export hash based on ALL transitive orphan modules.Edward Z. Yang2016-10-1815-10/+119
| | | | | | | | | | | | | | | | | | | 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
* Add some missing RTS symbolsSimon Marlow2016-10-181-0/+9
| | | | | | | | | | | | Test Plan: validate Reviewers: austin, bgamari, erikd Reviewed By: bgamari, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2589
* fix build failure on Solaris caused by usage of --export-dynamicKarel Gardas2016-10-181-0/+4
| | | | | | | | | | | | | Summary: This patch fixes build failure on Solaris which is caused by usage --export-dynamic linker parameter. This parameter is not supported by Solaris linker. The param itself was added by D2590 Reviewers: bgamari, simonmar, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2606
* ghc/Main.hs: Add import list to DynamicLoadingÖmer Sinan Ağacan2016-10-181-1/+1
|
* DynamicLoading: Replace map + zip with zipWithÖmer Sinan Ağacan2016-10-181-2/+2
|
* fixup! Add option to not retain CAFs to the linker APISimon Marlow2016-10-181-1/+1
|
* remove unnecessary ifdefSimon Marlow2016-10-181-2/+0
|
* Add option to not retain CAFs to the linker APISimon Marlow2016-10-182-3/+24
|
* Track dep_finsts in exports hash, as it affects downstream deps.Edward Z. Yang2016-10-1713-3/+137
| | | | | | | | | | | | | | | | | | | | 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
* Bump parallel submoduleBen Gamari2016-10-171-0/+0
| | | | Includes testsuite fix for Python 3.
* testsuite: Mark T7037 as broken on WindowsBen Gamari2016-10-171-1/+2
| | | | Due to #12725.
* testsuite/driver: Allow threading on WindowsBen Gamari2016-10-171-3/+0
| | | | | | | | | | | | | | | | It seems that threading now works fine. The only caveat here is that it makes some race conditions more likely (e.g. #12554), although these also appear to affect single-threaded runs. Test Plan: Validate on Windows Reviewers: austin, Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2600 GHC Trac Issues: #10510
* testsuite: Eliminate unnecessary compile_timeout_multiplierBen Gamari2016-10-171-1/+1
| | | | | | | | | | | | | | | | 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
* testsuite/driver: More Unicode awarenessBen Gamari2016-10-172-11/+16
| | | | | | | | | | | | | Explicitly specify utf8 encoding in a few spots which were failing on Windows with Python 3. Test Plan: Validate Reviewers: austin, thomie Differential Revision: https://phabricator.haskell.org/D2602 GHC Trac Issues: #9184
* validate: Allow user to override Python interpreterBen Gamari2016-10-171-2/+8
| | | | | | | | | | | | | | | Due to #12554 and #12661 we must be quite picky about our choice of Python interpreter on Windows. Allow the user to override it. Test Plan: `PYTHON=/usr/bin/python2 ./validate` on Windows Reviewers: austin, Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2603 GHC Trac Issues: #12554, #12661
* testsuite/timeout: Ensure that processes are cleaned up on WindowsBen Gamari2016-10-171-16/+19
| | | | | | | | | | | | | | Previously if the test is interrupted (e.g. with Ctrl-C) any processes which it spawned may not be properly terminated. Here we catch any exception and ensure that we job is terminated. Test Plan: Validate on Windows Reviewers: Phyx, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2599
* testsuite/driver: Never symlink on WindowsBen Gamari2016-10-171-6/+12
| | | | | | | | | | | | While msys' mingw Python 3 does indeed export `os.symlink`, it is unusable since creating symbolic links on Windows requires permissions that essentially no one has. Test Plan: Validate on Windows Reviewers: austin, Phyx, thomie Differential Revision: https://phabricator.haskell.org/D2604
* testsuite: Mark T9405 as broken on WindowsBen Gamari2016-10-172-2/+4
| | | | There seems to be a runtime system bug here, as described in #12714.
* testsuite: Mark T10858 as broken on WindowsBen Gamari2016-10-171-1/+2
| | | | | | | | 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.
* testsuite: Mark break011 as brokenBen Gamari2016-10-171-1/+4
| | | | See #12712.
* testsuite: Work around #12554Ben Gamari2016-10-171-2/+42
| | | | | | | | | | | | | | | | It seems that Python 2.7.11 and "recent" msys2 releases are broken, holding open file locks unexpected. This causes rmtree to intermittently fail. Even worse, it would fail silently (since we pass ignore_errors=True), causing makedirs to fail later. We now explicitly check for the existence of the test directory before attempting to delete it and disable ignore_errors. Moreover, on Windows we now try multiple times to rmtree the testdir, working around the apparently msys bug. This is all just terrible, but Phyx and I spent several hours trying to track down the issue to no available. The workaround is better than nothing.
* Re-add accidentally-deleted lineSimon Peyton Jones2016-10-171-1/+2
| | | | | | | | | | | | This adds a line I deleted by mistake in commit db71d971379c74dd1d2b958c11dc6c9e718a3e61 Author: Simon Peyton Jones <simonpj@microsoft.com> Date: Fri Oct 14 17:40:51 2016 +0100 Reduce trace output slightly Sorry about that!
* Typos in commentsGabor Greif2016-10-174-4/+4
|
* Comments onlySimon Peyton Jones2016-10-171-0/+13
|
* Add more variants of T3064 (in comments)Simon Peyton Jones2016-10-171-10/+13
|
* Reduce trace output slightlySimon Peyton Jones2016-10-171-4/+2
|
* Test Trac #12681Simon Peyton Jones2016-10-174-0/+11
|
* Fix wrapping order in matchExpectedConTySimon Peyton Jones2016-10-173-10/+24
| | | | | | | | 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.
* Correct order of existentials in pattern synonymsSimon Peyton Jones2016-10-174-18/+81
| | | | | | | | | 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.
* Typo in commentSimon Peyton Jones2016-10-171-1/+1
|
* Fix shadowing in mkWwBodiesSimon Peyton Jones2016-10-172-27/+55
| | | | | | | | | | | | | | | | | | This bug, exposed by Trac #12562 was very obscure, and has been lurking for a long time. What happened was that, in the worker/wrapper split a tyvar binder for a worker function accidentally shadowed an in-scope term variable that was mentioned in the body of the function It's jolly hard to provoke, so I have not even attempted to make a test case. There's a Note [Freshen WW arguments] to explain. Interestingly, fixing the bug (which meant fresher type variables) revealed a second lurking bug: I'd failed to apply the substitution to the coercion in the second last case of mkWWArgs, which introduces a Cast.
* Fix comment typoSimon Peyton Jones2016-10-171-1/+1
|
* Comments about -Wredundant-constraintsSimon Peyton Jones2016-10-172-7/+18
|
* Correct name of makeStableName in haddockReid Barton2016-10-161-1/+1
|