summaryrefslogtreecommitdiff
path: root/testsuite/tests
Commit message (Collapse)AuthorAgeFilesLines
* Fix #13833: accept type literals with no FlexibleInstancesKirill Zaborsky2018-06-152-0/+13
| | | | | | | | | | | | | | Test Plan: ./validate Reviewers: bgamari, simonpj Reviewed By: bgamari, simonpj Subscribers: simonpj, rwbarton, thomie, carter GHC Trac Issues: #13833 Differential Revision: https://phabricator.haskell.org/D4823
* Use data con name instead of parent in lookupRecFieldOccAdam Gundry2018-06-158-1/+38
| | | | | | | | | | | | | | Test Plan: new tests rename/should_compile/{T14747,T15149} Reviewers: simonpj, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14747, #15149 Differential Revision: https://phabricator.haskell.org/D4821
* Add "quantified constraint" context in error message, fix #15231.HE, Tao2018-06-1511-12/+39
| | | | | | | | | | | | | | | | | | | | This patch adds "quantified constraint" context in error message when UndecidableInstances checking fails for quantified constraints. See Trac #15231:comment#1. This patch also pretty-prints the instance head for better error messages. Test Plan: make test TEST="T15231" Reviewers: bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie, carter GHC Trac Issues: #15231 Differential Revision: https://phabricator.haskell.org/D4819
* testsuite: Make T4442 compile on i386 and mark as brokenBen Gamari2018-06-152-5/+32
| | | | | There are some rather suspicious failures in the 64-bit case. See #15184 for details.
* Make better "fake tycons" in error recoverySimon Peyton Jones2018-06-153-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider (Trac #15215) data T a = MkT ... data S a = ...T...MkT.... If there is an error in the definition of 'T' we add a "fake type constructor" to the type environment, so that we can continue to typecheck 'S'. But we /were not/ adding a fake anything for 'MkT' and so there was an internal error when we met 'MkT' in the body of 'S'. The fix is to add fake tycons for all the 'implicits' of 'T'. This is done by mk_fake_tc in TcTyClsDecls.checkValidTyCl, which now returns a /list/ of TyCons rather than just one. On the way I did some refactoring: * Rename TcTyDecls.tcAddImplicits to tcAddTyConsToGblEnv and make it /include/ the TyCons themeselves as well as their implicits * Some incidental refactoring about tcRecSelBinds. The main thing is that I've avoided creating a HsValBinds that we immediately decompose. That meant moving some deck chairs around. NB: The new error message for the regression test T15215 has the opaque error "Illegal constraint in a type:", flagged in Trac #14845. But that's the fault of the latter ticket. The fix here not to blame.
* Fix binary and haddock submodule commitsBen Gamari2018-06-141-4/+6
|
* Embrace -XTypeInType, add -XStarIsTypeVladislav Zavialov2018-06-14336-912/+1081
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Implement the "Embrace Type :: Type" GHC proposal, .../ghc-proposals/blob/master/proposals/0020-no-type-in-type.rst GHC 8.0 included a major change to GHC's type system: the Type :: Type axiom. Though casual users were protected from this by hiding its features behind the -XTypeInType extension, all programs written in GHC 8+ have the axiom behind the scenes. In order to preserve backward compatibility, various legacy features were left unchanged. For example, with -XDataKinds but not -XTypeInType, GADTs could not be used in types. Now these restrictions are lifted and -XTypeInType becomes a redundant flag that will be eventually deprecated. * Incorporate the features currently in -XTypeInType into the -XPolyKinds and -XDataKinds extensions. * Introduce a new extension -XStarIsType to control how to parse * in code and whether to print it in error messages. Test Plan: Validate Reviewers: goldfire, hvr, bgamari, alanz, simonpj Reviewed By: goldfire, simonpj Subscribers: rwbarton, thomie, mpickering, carter GHC Trac Issues: #15195 Differential Revision: https://phabricator.haskell.org/D4748
* Fix deserialization of docs (#15240)Simon Jakobi2018-06-141-13/+13
| | | | | | | | | | | | | | | | | | | | We were using Map.fromDistinctAscList to deserialize a (Map Name HsDocString). As the Names' Uniques had changed, we ended up with an invalid map in which we couldn't lookup certain keys. Switching to Map.fromList fixed the issue. Added comments in several places. Reviewers: alexbiehl, hvr, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15240 Differential Revision: https://phabricator.haskell.org/D4816
* Mark test broken on powerpc64[le]Peter Trommler2018-06-142-1/+3
| | | | | | | | | | | | | | | | | | | Test num009 fails different results. #15062 lists more issues on other platforms. Test T14894 fails because DWARF support is not implemented in the PowerPC native code backend. T5435_v_asm_b fails because the runtime linker is not implemented for PowerPC 64-bit systems. Test Plan: validate Reviewers: bgamari, hvr, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #13634, #11261, #11259, #15062 Differential Revision: https://phabricator.haskell.org/D4825
* Make Control.Exception.throw levity polymorphic.Félix Baylac-Jacqué2018-06-142-0/+12
| | | | | | | | | | | | | | Test Plan: Validate. Reviewers: hvr, bgamari, sighingnow Reviewed By: sighingnow Subscribers: tdammers, sighingnow, rwbarton, thomie, carter GHC Trac Issues: #15180 Differential Revision: https://phabricator.haskell.org/D4827
* Disable `-fdefer-out-of-scope-variables` in ghci.HE, Tao2018-06-1413-0/+29
| | | | | | | | | | | | | | | | | | | | We have already disabled `-fdefer-type-errors` and `-fdefer-typed-holes` in ghci. This patch disables `-fdefer-out-of-scope-variables` as well. Fixes Trac #15259, as well as #14963. Test Plan: make test TEST="T15259 T14963a T14963b T14963c" Reviewers: bgamari, tdammers Reviewed By: tdammers Subscribers: tdammers, rwbarton, thomie, carter GHC Trac Issues: #15259, #14963 Differential Revision: https://phabricator.haskell.org/D4830
* testsuite: Fix T4442 on i386Ben Gamari2018-06-141-0/+3
| | | | | | | | | | | | | | Test Plan: Validate on i386 Reviewers: tdammers Reviewed By: tdammers Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15184 Differential Revision: https://phabricator.haskell.org/D4838
* testsuite: Add Windows-specific output for T5611Ben Gamari2018-06-141-0/+1
| | | | | | | | | | | | | It's not entirely clear why this is necessary, but this currently fails on Windows and the difference seems rather minor. Test Plan: Validate on Windows Reviewers: Phyx Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4842
* testsuite: Add -fghci-leak-check to expected output on mingw32Ben Gamari2018-06-142-0/+8
| | | | | | | | Test Plan: Validate on Windows Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4843
* Disable T12903 on Darwin due to flakinessTamar Christina2018-06-141-2/+4
| | | | | | | | | | | | | | | Test seems to randomly fail on harbormaster and CircleCI. Disabling it until it can be fixed. Test Plan: make test TEST=T12903 Reviewers: austin, bgamari, simonmar, mpickering Reviewed By: mpickering Subscribers: mpickering, thomie, qnikst GHC Trac Issues: #12903
* Do not skip conc004 in GHCi wayÖmer Sinan Ağacan2018-06-141-4/+1
| | | | | | | | | | | | | | | | | According to the comments it used to allocate too much, but currently I get 205,987,176 bytes allocated in the heap 50,352,200 bytes copied during GC 14,244,968 bytes maximum residency (6 sample(s)) 172,952 bytes maximum slop 36 MB total memory in use (0 MB lost due to fragmentation) Reviewers: bgamari, tdammers, simonmar Subscribers: tdammers, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4831
* Fix some of the failures in sanity wayÖmer Sinan Ağacan2018-06-131-13/+13
| | | | | | | | | | | | | | | Tests for runtime argument parsing should only run in normal way to avoid breakage caused by way-specific RTS arguments. Reviewers: bgamari, AndreasK, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15241 Differential Revision: https://phabricator.haskell.org/D4839
* Refactor TcExpr.tcSeqSimon Peyton Jones2018-06-121-2/+2
| | | | | | | | | | | | | | | | | | The function TcExpr.tcSeq seemed much longer that is really justifiable; and was set to get worse with the fix to Trac #15242. This patch refactors the special cases for function applications, so that the special case for 'seq' can use the regular tcFunApp, which makes the code both clearer and shorter. And smooths the way for #15242. The special case for 'tagToEnum#' is even more weird and ad-hoc, so I refrained from meddling iwth it for now. I also combined HsUtils.mkHsAppType and mkHsAppTypeOut, so that I could have a single 'wrapHsArgs' function, thereby fixing a ToDo from Alan Zimmerman. That means tha tmkHsAppType now has an equality predicate, but I guess that's fair enough.
* Remove duplicate quantified constraintsSimon Peyton Jones2018-06-112-0/+70
| | | | | | | This is an easy fix for Trac #15244: just avoid adding the same quantified Given constraint to the inert set twice. See TcSMonad Note [Do not add duplicate quantified instances].
* Make seq# evaluatedness look through castsDavid Feuer2018-06-112-0/+42
| | | | | | | | | | | | | In d964b05, I forgot to look through casts to find the `seq#` identifier. Fix that. Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4804
* testsuite: Remove uniques from T15243's stderr outputBen Gamari2018-06-101-10/+10
|
* testsuite: Suppress uniques in T15243 outputBen Gamari2018-06-101-1/+1
| | | | Fixes test for #15243.
* testsuite: Bump performance metrics of T9233 and T13035Ben Gamari2018-06-101-2/+4
| | | | | Unfortunately it's very unclear which commit caused these two to regress; they only fail on Darwin and not even deterministically it sesems.
* Do not omit T4030 in GHCi modeÖmer Sinan Ağacan2018-06-101-2/+1
| | | | | | | | | | | | (it currently works fine in GHCi) Reviewers: bgamari Reviewed By: bgamari Subscribers: simonmar, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4824
* Fix `print-explicit-runtime-reps` (#11786).HE, Tao2018-06-0826-241/+226
| | | | | | | | | | | | | | By fixing splitting of IfaceTypes in splitIfaceSigmaTy. Test Plan: make test TEST="T11549 T11376 T11786" Reviewers: goldfire, bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #11786, #11376 Differential Revision: https://phabricator.haskell.org/D4733
* typecheck: Don't warn about "redundant" TypeError constraintsBen Gamari2018-06-071-2/+1
| | | | | | | | | | | | Summary: This fixes #15232, where we would warn about `TypeError` constraints being redundant. Test Plan: Validate Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15232 Differential Revision: https://phabricator.haskell.org/D4808
* Allow Haddock comments before function arguments.Iavor Diatchki2018-06-073-2/+42
| | | | | | | | | | | | | | | Currently, documentation strings on function arguments has to be written after the argument (i.e., using `{-^ -}` comments). This patch allows us to use `{-| -}` comments to put the comment string before an argument. The same works for the results of functions. Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, mpickering, carter Differential Revision: https://phabricator.haskell.org/D4767
* Run typeCheckResultAction and renamedResultAction in TcM rather than HscMatthew Pickering2018-06-072-3/+3
| | | | | | | | | | | | | | | | | The primary motivation for this is that this allows users to access the warnings and error machinery present in TcM. However, it also allows users to use TcM actions which means they can typecheck GhcPs which could be significantly easier than constructing GhcTc. Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15229 Differential Revision: https://phabricator.haskell.org/D4792
* Fix #15236 by removing parentheses from funTyConNameRyan Scott2018-06-074-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, `funTyConName` is defined as: ```lang=haskell funTyConName = mkPrimTyConName (fsLit "(->)") funTyConKey funTyCon ``` What's strange about this definition is that there are extraneous parentheses around `->`, which is quite unlike every other infix `Name`. As a result, the `:info (->)` output is totally garbled (see Trac #15236). It's quite straightforward to fix that particular bug by removing the extraneous parentheses. However, it turns out that this makes some test output involving `Show` instances for `TypeRep` look less appealing, since `->` is no longer surrounded with parentheses when applied prefix. But neither were any /other/ infix type constructors! The right fix there was to change `showTypeable` to put parentheses around prefix applications of infix tycons. Test Plan: ./validate Reviewers: bgamari, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15236 Differential Revision: https://phabricator.haskell.org/D4799
* Don't expose (~#), (~R#), (~P#) from GHC.PrimRyan Scott2018-06-077-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, the primitive `(~#)`, `(~R#)`, and `(~P#)` type constructors are wired in to be exported from `GHC.Prim`. This has some unfortunate consequences, however. It turns out that `(~#)` is actually a legal infix identifier, so users can make use of unboxed equalities in strange ways in user code (see #15209). The other two, `(~R#)` and `(~P#)`, can't be used in source code, but they can be observed with GHCi's `:browse` command, which is somewhat unnerving. The fix for both of these problems is simple: just don't wire them to be exported from `GHC.Prim`. Test Plan: make test TEST="T12023 T15209" Reviewers: bgamari, dfeuer Reviewed By: bgamari, dfeuer Subscribers: rwbarton, thomie, carter, dfeuer GHC Trac Issues: #12023, #15209 Differential Revision: https://phabricator.haskell.org/D4801
* testsuite: Skip T13838 in ghci wayBen Gamari2018-06-071-1/+3
| | | | | | | | | | | | | | Test Plan: `make slowtest TEST=T13838` Reviewers: alpmestan, dfeuer Reviewed By: dfeuer Subscribers: dfeuer, rwbarton, thomie, carter GHC Trac Issues: #15238 Differential Revision: https://phabricator.haskell.org/D4802
* Fix #15243 by fixing incorrect uses of NotPromotedRyan Scott2018-06-075-4/+32
| | | | | | | | | | | | | | | | | | | In `Convert`, we were incorrectly using `NotPromoted` to denote type constructors that were actually intended to be promoted, resulting in poor `-ddump-splices` output (as seen in #15243). Easily fixed. Test Plan: make test TEST=T15243 Reviewers: bgamari, goldfire Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15243 Differential Revision: https://phabricator.haskell.org/D4809
* testsuite: Add test for #15232Ben Gamari2018-06-072-0/+13
| | | | | | | | Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15232 Differential Revision: https://phabricator.haskell.org/D4807
* Move 'HsBangTy' out in constructor argumentsAlec Theriault2018-06-075-0/+37
| | | | | | | | | | | | | | | | | | | | When run with -haddock, a constructor argument can have both a a strictness/unpackedness annotation and a docstring. The parser binds 'HsBangTy' more tightly than 'HsDocTy', yet for constructor arguments we really need the 'HsBangTy' on the outside. This commit does this shuffling in the 'mkConDeclH98' and 'mkGadtDecl' smart constructors. Test Plan: haddockA038, haddockC038 Reviewers: bgamari, dfeuer Reviewed By: bgamari Subscribers: dfeuer, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4727
* Check if both branches of an Cmm if have the same target.klebinger.andreas@gmx.at2018-06-074-0/+16
| | | | | | | | | | | | | | | | | | | | This for some reason or the other and makes it into the final binary. I've added the check to ContFlowOpt as that seems like a logical place for this. In a regular nofib run there were 30 occurences of this pattern. Test Plan: ci Reviewers: bgamari, simonmar, dfeuer, jrtc27, tdammers Reviewed By: bgamari, simonmar Subscribers: tdammers, dfeuer, rwbarton, thomie, carter GHC Trac Issues: #15188 Differential Revision: https://phabricator.haskell.org/D4740
* Fix unparseable pretty-printing of promoted data consAndreas Herrmann2018-06-0710-23/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would print code which would not round-trip: ``` > :set -XDataKinds > :set -XPolyKinds > data Proxy k = Proxy > _ :: Proxy '[ 'True ] error: Found hole: _ :: Proxy '['True] > _ :: Proxy '['True] error: Invalid type signature: _ :: ... Should be of form <variable> :: <type> ``` Test Plan: Validate with T14343 Reviewers: RyanGlScott, goldfire, bgamari, tdammers Reviewed By: RyanGlScott, bgamari Subscribers: tdammers, rwbarton, thomie, carter GHC Trac Issues: #14343 Differential Revision: https://phabricator.haskell.org/D4746
* testsuite: Fix dynamic-paper stderr fileBen Gamari2018-06-071-1/+15
| | | | The stderr file was empty, yet GHC fails with an error.
* Remove ad-hoc special case in occAnalSimon Peyton Jones2018-06-079-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back in 1999 I put this ad-hoc code in the Case-handling code for occAnal: occAnal env (Case scrut bndr ty alts) = ... -- Note [Case binder usage] -- ~~~~~~~~~~~~~~~~~~~~~~~~ -- The case binder gets a usage of either "many" or "dead", never "one". -- Reason: we like to inline single occurrences, to eliminate a binding, -- but inlining a case binder *doesn't* eliminate a binding. -- We *don't* want to transform -- case x of w { (p,q) -> f w } -- into -- case x of w { (p,q) -> f (p,q) } tag_case_bndr usage bndr = (usage', setIdOccInfo bndr final_occ_info) where occ_info = lookupDetails usage bndr usage' = usage `delDetails` bndr final_occ_info = case occ_info of IAmDead -> IAmDead _ -> noOccInfo But the comment looks wrong -- the bad inlining will not happen -- and I think it relates to some long-ago version of the simplifier. So I simply removed the special case, which gives more accurate occurrence-info to the case binder. Interestingly I got a slight improvement in nofib binary sizes. -------------------------------------------------------------------------------- Program Size Allocs Runtime Elapsed TotalMem -------------------------------------------------------------------------------- cacheprof -0.1% +0.2% -0.7% -1.2% +8.6% -------------------------------------------------------------------------------- Min -0.2% 0.0% -14.5% -30.5% 0.0% Max -0.1% +0.2% +10.0% +10.0% +25.0% Geometric Mean -0.2% +0.0% -1.9% -5.4% +0.3% I have no idea if the improvement in runtime is real. I did look at the tiny increase in allocation for cacheprof and concluded that it was unimportant (I forget the details). Also the more accurate occ-info for the case binder meant that some inlining happens in one pass that previously took successive passes for the test dependent/should_compile/dynamic-paper (which has a known Russel-paradox infinite loop in the simplifier). In short, a small win: less ad-hoc complexity and slightly smaller binaries.
* Let the simplifier know that seq# forcesDavid Feuer2018-06-062-0/+40
| | | | | | | | | | | | | | | Add a special case in `simplAlt` to record that the result of `seq#` is in WHNF. Reviewers: simonmar, bgamari, simonpj Reviewed By: simonpj Subscribers: simonpj, rwbarton, thomie, carter GHC Trac Issues: #15226 Differential Revision: https://phabricator.haskell.org/D4796
* Introduce DerivingViaRyan Scott2018-06-0414-2/+599
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the `DerivingVia` proposal put forth in https://github.com/ghc-proposals/ghc-proposals/pull/120. This introduces the `DerivingVia` deriving strategy. This is a generalization of `GeneralizedNewtypeDeriving` that permits the user to specify the type to `coerce` from. The major change in this patch is the introduction of the `ViaStrategy` constructor to `DerivStrategy`, which takes a type as a field. As a result, `DerivStrategy` is no longer a simple enumeration type, but rather something that must be renamed and typechecked. The process by which this is done is explained more thoroughly in section 3 of this paper ( https://www.kosmikus.org/DerivingVia/deriving-via-paper.pdf ), although I have inlined the relevant parts into Notes where possible. There are some knock-on changes as well. I took the opportunity to do some refactoring of code in `TcDeriv`, especially the `mkNewTypeEqn` function, since it was bundling all of the logic for (1) deriving instances for newtypes and (2) `GeneralizedNewtypeDeriving` into one huge broth. `DerivingVia` reuses much of part (2), so that was factored out as much as possible. Bumps the Haddock submodule. Test Plan: ./validate Reviewers: simonpj, bgamari, goldfire, alanz Subscribers: alanz, goldfire, rwbarton, thomie, mpickering, carter GHC Trac Issues: #15178 Differential Revision: https://phabricator.haskell.org/D4684
* Serialize docstrings to ifaces, display them with new GHCi :doc commandSimon Jakobi2018-06-0428-78/+185
| | | | | | | | | | | | | | | | | | | | | | | | If `-haddock` is set, we now extract docstrings from the renamed ast and serialize them in the .hi-files. This includes some of the changes from D4749 with the notable exceptions of the docstring lexing and renaming. A currently limited and experimental GHCi :doc command can be used to display docstrings for declarations. The formatting of pretty-printed docstrings is changed slightly, causing some changes in testsuite/tests/haddock. Test Plan: ./validate Reviewers: alexbiehl, hvr, gershomb, harpocrates, bgamari Reviewed By: alexbiehl Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4758
* Implement QuantifiedConstraintsSimon Peyton Jones2018-06-0418-6/+342
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have wanted quantified constraints for ages and, as I hoped, they proved remarkably simple to implement. All the machinery was already in place. The main ticket is Trac #2893, but also relevant are #5927 #8516 #9123 (especially! higher kinded roles) #14070 #14317 The wiki page is https://ghc.haskell.org/trac/ghc/wiki/QuantifiedConstraints which in turn contains a link to the GHC Proposal where the change is specified. Here is the relevant Note: Note [Quantified constraints] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The -XQuantifiedConstraints extension allows type-class contexts like this: data Rose f x = Rose x (f (Rose f x)) instance (Eq a, forall b. Eq b => Eq (f b)) => Eq (Rose f a) where (Rose x1 rs1) == (Rose x2 rs2) = x1==x2 && rs1 >= rs2 Note the (forall b. Eq b => Eq (f b)) in the instance contexts. This quantified constraint is needed to solve the [W] (Eq (f (Rose f x))) constraint which arises form the (==) definition. Here are the moving parts * Language extension {-# LANGUAGE QuantifiedConstraints #-} and add it to ghc-boot-th:GHC.LanguageExtensions.Type.Extension * A new form of evidence, EvDFun, that is used to discharge such wanted constraints * checkValidType gets some changes to accept forall-constraints only in the right places. * Type.PredTree gets a new constructor ForAllPred, and and classifyPredType analyses a PredType to decompose the new forall-constraints * Define a type TcRnTypes.QCInst, which holds a given quantified constraint in the inert set * TcSMonad.InertCans gets an extra field, inert_insts :: [QCInst], which holds all the Given forall-constraints. In effect, such Given constraints are like local instance decls. * When trying to solve a class constraint, via TcInteract.matchInstEnv, use the InstEnv from inert_insts so that we include the local Given forall-constraints in the lookup. (See TcSMonad.getInstEnvs.) * topReactionsStage calls doTopReactOther for CIrredCan and CTyEqCan, so they can try to react with any given quantified constraints (TcInteract.matchLocalInst) * TcCanonical.canForAll deals with solving a forall-constraint. See Note [Solving a Wanted forall-constraint] Note [Solving a Wanted forall-constraint] * We augment the kick-out code to kick out an inert forall constraint if it can be rewritten by a new type equality; see TcSMonad.kick_out_rewritable Some other related refactoring ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Move SCC on evidence bindings to post-desugaring, which fixed #14735, and is generally nicer anyway because we can use existing CoreSyn free-var functions. (Quantified constraints made the free-vars of an ev-term a bit more complicated.) * In LookupInstResult, replace GenInst with OneInst and NotSure, using the latter for multiple matches and/or one or more unifiers
* Fix broken test T14547.HE, Tao2018-06-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | Phab:D4571 lags behind HEAD for too many commits. The commit of Phab:4571 1f88f541aad1e36d01f22f9e71dfbc247e6558e2 brought some unintentional changes (not belong to [Phab:4571's Diff 16314](https://phabricator.haskell.org/differential/diff/16314/)) into ghc-head, breaking T14557. Let's fix that. Test Plan: make test TEST="T14547" Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #15222 Differential Revision: https://phabricator.haskell.org/D4778
* Expand type synonyms when Linting a forallSimon Peyton Jones2018-06-042-0/+20
| | | | | | | | | | | | | | | Trac #14939 showed a type like type Alg cls ob = ob f :: forall (cls :: * -> Constraint) (b :: Alg cls *). b where the kind of the forall looks like (Alg cls *), with a free cls. This tripped up Core Lint. I fixed this by making Core Lint a bit more forgiving, expanding type synonyms if necessary. I'm worried that this might not be the whole story; notably typeKind looks suspect. But it certainly fixes this problem.
* testsuite: Really mark T14547 as brokenBen Gamari2018-06-031-1/+0
|
* testsuite: Mark T14547 as brokenBen Gamari2018-06-031-0/+1
|
* Add tests for #8128 and #8740Ryan Scott2018-06-035-0/+60
| | | | | Commit 08073e16cf672d8009309e4e55d4566af1ecaff4 (#11066) ended up fixing these, fortunately enough.
* Improve exhaustiveness checking for literal values and patterns, fix #14546HE, Tao2018-06-038-0/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we parse both the **integral literal** value and the patterns as `OverLit HsIntegral`. For example: ``` case 0::Int of 0 -> putStrLn "A" 1 -> putStrLn "B" _ -> putStrLn "C" ``` When checking the exhaustiveness of pattern matching, we translate the `0` in value position as `PmOLit`, but translate the `0` and `1` in pattern position as `PmSLit`. The inconsistency leads to the failure of `eqPmLit` to detect the equality and report warning of "Pattern match is redundant" on pattern `0`, as reported in #14546. In this patch we remove the specialization of `OverLit` patterns, and keep the overloaded number literal in pattern as it is to maintain the consistency. Now we can capture the exhaustiveness of pattern `0` and the redundancy of pattern `1` and `_`. For **string literals**, we parse the string literals as `HsString`. When `OverloadedStrings` is enabled, it further be turned as `HsOverLit HsIsString`, whether it's type is `String` or not. For example: ``` case "foo" of "foo" -> putStrLn "A" "bar" -> putStrLn "B" "baz" -> putStrLn "C" ``` Previously, the overloaded string values are translated to `PmOLit` and the non-overloaded string values are translated to `PmSLit`. However the string patterns, both overloaded and non-overloaded, are translated to list of characters. The inconsistency leads to wrong warnings about redundant and non-exhaustive pattern matching warnings, as reported in #14546. In order to catch the redundant pattern in following case: ``` case "foo" of ('f':_) -> putStrLn "A" "bar" -> putStrLn "B" ``` In this patch, we translate non-overloaded string literals, both in value position and pattern position, as list of characters. For overloaded string literals, we only translate it to list of characters only when it's type is `stringTy`, since we know nothing about the `toString` methods. But we know that if two overloaded strings are syntax equal, then they are equal. Then if it's type is not `stringTy`, we just translate it to `PmOLit`. We can still capture the exhaustiveness of pattern `"foo"` and the redundancy of pattern `"bar"` and `"baz"` in the following code: ``` {-# LANGUAGE OverloadedStrings #-} main = do case "foo" of "foo" -> putStrLn "A" "bar" -> putStrLn "B" "baz" -> putStrLn "C" ``` Test Plan: make test TEST="T14546" Reviewers: bgamari, simonpj Reviewed By: bgamari, simonpj Subscribers: simonpj, thomie, carter GHC Trac Issues: #14546 Differential Revision: https://phabricator.haskell.org/D4571
* Turn "inaccessible code" error into a warningTobias Dammers2018-06-0211-41/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With GADTs, it is possible to write programs such that the type constraints make some code branches inaccessible. Take, for example, the following program :: {-# LANGUAGE GADTs #-} data Foo a where Foo1 :: Foo Char Foo2 :: Foo Int data TyEquality a b where Refl :: TyEquality a a checkTEQ :: Foo t -> Foo u -> Maybe (TyEquality t u) checkTEQ x y = error "unimportant" step2 :: Bool step2 = case checkTEQ Foo1 Foo2 of Just Refl -> True -- Inaccessible code Nothing -> False Clearly, the `Just Refl` case cannot ever be reached, because the `Foo1` and `Foo2` constructors say `t ~ Char` and `u ~ Int`, while the `Refl` constructor essentially mandates `t ~ u`, and thus `Char ~ Int`. Previously, GHC would reject such programs entirely; however, in practice this is too harsh. Accepting such code does little harm, since attempting to use the "impossible" code will still produce errors down the chain, while rejecting it means we cannot legally write or generate such code at all. Hence, we turn the error into a warning, and provide `-Winaccessible-code` to control GHC's behavior upon encountering this situation. Test Plan: ./validate Reviewers: bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, carter GHC Trac Issues: #11066 Differential Revision: https://phabricator.haskell.org/D4744
* Fix a bad interaction between GADTs and COMPLETE setsRyan Scott2018-06-023-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As observed in #14059 (starting at comment 5), the error messages surrounding a program involving GADTs and a `COMPLETE` set became worse between 8.2 and 8.4. The culprit was a new validity check in 8.4 which filters out `COMPLETE` set candidates if a return type of any conlike in the set doesn't match the type of the scrutinee. However, this check was too conservative, since it removed perfectly valid `COMPLETE` sets that contained GADT constructors, which quite often have return types that don't match the type of a scrutinee. To fix this, I adopted the most straightforward possible solution of only performing this validity check on //pattern synonym// constructors, not //data// constructors. Note that this does not fix #14059 entirely, but instead simply fixes a particular buglet that was discovered in that ticket. Test Plan: make test TEST=T14059 Reviewers: bgamari, mpickering Reviewed By: mpickering Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14059 Differential Revision: https://phabricator.haskell.org/D4752