Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ghc/ghc
  • bgamari/ghc
  • syd/ghc
  • ggreif/ghc
  • watashi/ghc
  • RolandSenn/ghc
  • mpickering/ghc
  • DavidEichmann/ghc
  • carter/ghc
  • harpocrates/ghc
  • ethercrow/ghc
  • mijicd/ghc
  • adamse/ghc
  • alexbiehl/ghc
  • gridaphobe/ghc
  • trofi/ghc
  • supersven/ghc
  • ppk/ghc
  • ulysses4ever/ghc
  • AndreasK/ghc
  • ghuntley/ghc
  • shayne-fletcher-da/ghc
  • fgaz/ghc
  • yav/ghc
  • osa1/ghc
  • mbbx6spp/ghc
  • JulianLeviston/ghc
  • reactormonk/ghc
  • rae/ghc
  • takenobu-hs/ghc
  • michalt/ghc
  • andrewthad/ghc
  • hsyl20/ghc
  • scottgw/ghc
  • sjakobi/ghc
  • angerman/ghc
  • RyanGlScott/ghc
  • hvr/ghc
  • howtonotwin/ghc
  • chessai/ghc
  • m-renaud/ghc
  • brprice/ghc
  • stevehartdata/ghc
  • sighingnow/ghc
  • kgardas/ghc
  • ckoparkar/ghc
  • alp/ghc
  • smaeul/ghc
  • kakkun61/ghc
  • sykloid/ghc
  • newhoggy/ghc
  • toonn/ghc
  • nineonine/ghc
  • Phyx/ghc
  • ezyang/ghc
  • tweag/ghc
  • langston/ghc
  • ndmitchell/ghc
  • rockbmb/ghc
  • artempyanykh/ghc
  • mniip/ghc
  • mynguyenbmc/ghc
  • alexfmpe/ghc
  • crockeea/ghc
  • nh2/ghc
  • vaibhavsagar/ghc
  • phadej/ghc
  • Haskell-mouse/ghc
  • lolotp/ghc
  • spacekitteh/ghc
  • michaelpj/ghc
  • mgsloan/ghc
  • HPCohen/ghc
  • tmobile/ghc
  • radrow/ghc
  • simonmar/ghc
  • _deepfire/ghc
  • Ericson2314/ghc
  • leitao/ghc
  • fumieval/ghc
  • trac-isovector/ghc
  • cblp/ghc
  • xich/ghc
  • ciil/ghc
  • erthalion/ghc
  • xldenis/ghc
  • autotaker/ghc
  • haskell-wasm/ghc
  • kcsongor/ghc
  • agander/ghc
  • Baranowski/ghc
  • trac-dredozubov/ghc
  • 23Skidoo/ghc
  • iustin/ghc
  • ningning/ghc
  • josefs/ghc
  • kabuhr/ghc
  • gallais/ghc
  • dten/ghc
  • expipiplus1/ghc
  • Pluralia/ghc
  • rohanjr/ghc
  • intricate/ghc
  • kirelagin/ghc
  • Javran/ghc
  • DanielG/ghc
  • trac-mizunashi_mana/ghc
  • pparkkin/ghc
  • bollu/ghc
  • ntc2/ghc
  • jaspervdj/ghc
  • JoshMeredith/ghc
  • wz1000/ghc
  • zkourouma/ghc
  • code5hot/ghc
  • jdprice/ghc
  • tdammers/ghc
  • J-mie6/ghc
  • trac-lantti/ghc
  • ch1bo/ghc
  • cgohla/ghc
  • lucamolteni/ghc
  • acairncross/ghc
  • amerocu/ghc
  • chreekat/ghc
  • txsmith/ghc
  • trupill/ghc
  • typetetris/ghc
  • sergv/ghc
  • fryguybob/ghc
  • erikd/ghc
  • trac-roland/ghc
  • setupminimal/ghc
  • Friede80/ghc
  • SkyWriter/ghc
  • xplorld/ghc
  • abrar/ghc
  • obsidiansystems/ghc
  • Icelandjack/ghc
  • adinapoli/ghc
  • trac-matthewbauer/ghc
  • heatsink/ghc
  • dwijnand/ghc
  • Cmdv/ghc
  • alinab/ghc
  • pepeiborra/ghc
  • fommil/ghc
  • luochen1990/ghc
  • rlupton20/ghc
  • applePrincess/ghc
  • lehins/ghc
  • ronmrdechai/ghc
  • leeadam/ghc
  • harendra/ghc
  • mightymosquito1991/ghc
  • trac-gershomb/ghc
  • lucajulian/ghc
  • Rizary/ghc
  • VictorCMiraldo/ghc
  • jamesbrock/ghc
  • andrewdmeier/ghc
  • luke/ghc
  • pranaysashank/ghc
  • cocreature/ghc
  • hithroc/ghc
  • obreitwi/ghc
  • slrtbtfs/ghc
  • kaol/ghc
  • yairchu/ghc
  • Mathemagician98/ghc
  • trac-taylorfausak/ghc
  • leungbk/ghc
  • MichaWiedenmann/ghc
  • chris-martin/ghc
  • TDecki/ghc
  • adithyaov/ghc
  • trac-gelisam/ghc
  • Lysxia/ghc
  • complyue/ghc
  • bwignall/ghc
  • sternmull/ghc
  • sonika/ghc
  • leif/ghc
  • broadwaylamb/ghc
  • myszon/ghc
  • danbroooks/ghc
  • Mechachleopteryx/ghc
  • zardyh/ghc
  • trac-vdukhovni/ghc
  • OmarKhaledAbdo/ghc
  • arrowd/ghc
  • Bodigrim/ghc
  • matheus23/ghc
  • cardenaso11/ghc
  • trac-Athas/ghc
  • mb720/ghc
  • DylanZA/ghc
  • liff/ghc
  • typedrat/ghc
  • trac-claude/ghc
  • jbm/ghc
  • Gertjan423/ghc
  • PHO/ghc
  • JKTKops/ghc
  • kockahonza/ghc
  • msakai/ghc
  • Sir4ur0n/ghc
  • barambani/ghc
  • vishnu.c/ghc
  • dcoutts/ghc
  • trac-runeks/ghc
  • trac-MaxGabriel/ghc
  • lexi.lambda/ghc
  • strake/ghc
  • spavikevik/ghc
  • JakobBruenker/ghc
  • rmanne/ghc
  • gdziadkiewicz/ghc
  • ani/ghc
  • iliastsi/ghc
  • smunix/ghc
  • judah/ghc
  • blackgnezdo/ghc
  • emilypi/ghc
  • trac-bpfoley/ghc
  • muesli4/ghc
  • trac-gkaracha/ghc
  • Kleidukos/ghc
  • nek0/ghc
  • TristanCacqueray/ghc
  • dwulive/ghc
  • mbakke/ghc
  • arybczak/ghc
  • Yang123321/ghc
  • maksbotan/ghc
  • QuietMisdreavus/ghc
  • trac-olshanskydr/ghc
  • emekoi/ghc
  • samuela/ghc
  • josephcsible/ghc
  • dramforever/ghc
  • lpsmith/ghc
  • DenisFrezzato/ghc
  • michivi/ghc
  • jneira/ghc
  • jeffhappily/ghc
  • Ivan-Yudin/ghc
  • nakaji-dayo/ghc
  • gdevanla/ghc
  • galen/ghc
  • fendor/ghc
  • yaitskov/ghc
  • rcythr/ghc
  • awpr/ghc
  • jeremyschlatter/ghc
  • Aver1y/ghc
  • mitchellvitez/ghc
  • merijn/ghc
  • tomjaguarpaw1/ghc
  • trac-NoidedSuper/ghc
  • erewok/ghc
  • trac-junji.hashimoto/ghc
  • adamwespiser/ghc
  • bjaress/ghc
  • jhrcek/ghc
  • leonschoorl/ghc
  • lukasz-golebiewski/ghc
  • sheaf/ghc
  • last-g/ghc
  • carassius1014/ghc
  • eschwartz/ghc
  • dwincort/ghc
  • felixwiemuth/ghc
  • TimWSpence/ghc
  • marcusmonteirodesouza/ghc
  • WJWH/ghc
  • vtols/ghc
  • theobat/ghc
  • BinderDavid/ghc
  • ckoparkar0/ghc
  • alexander-kjeldaas/ghc
  • dme2/ghc
  • philderbeast/ghc
  • aaronallen8455/ghc
  • rayshih/ghc
  • benkard/ghc
  • mpardalos/ghc
  • saidelman/ghc
  • leiftw/ghc
  • ca333/ghc
  • bwroga/ghc
  • nmichael44/ghc
  • trac-crobbins/ghc
  • felixonmars/ghc
  • adityagupta1089/ghc
  • hgsipiere/ghc
  • treeowl/ghc
  • alexpeits/ghc
  • CraigFe/ghc
  • dnlkrgr/ghc
  • kerckhove_ts/ghc
  • cptwunderlich/ghc
  • eiais/ghc
  • hahohihu/ghc
  • sanchayan/ghc
  • lemmih/ghc
  • sehqlr/ghc
  • trac-dbeacham/ghc
  • luite/ghc
  • trac-f-a/ghc
  • vados/ghc
  • luntain/ghc
  • fatho/ghc
  • alexbiehl-gc/ghc
  • dcbdan/ghc
  • tvh/ghc
  • liam-ly/ghc
  • timbobbarnes/ghc
  • GovanifY/ghc
  • shanth2600/ghc
  • gliboc/ghc
  • duog/ghc
  • moxonsghost/ghc
  • zander/ghc
  • masaeedu/ghc
  • georgefst/ghc
  • guibou/ghc
  • nicuveo/ghc
  • mdebruijne/ghc
  • stjordanis/ghc
  • emiflake/ghc
  • wygulmage/ghc
  • frasertweedale/ghc
  • coot/ghc
  • aratamizuki/ghc
  • tsandstr/ghc
  • mrBliss/ghc
  • Anton-Latukha/ghc
  • tadfisher/ghc
  • vapourismo/ghc
  • Sorokin-Anton/ghc
  • basile-henry/ghc
  • trac-mightybyte/ghc
  • AbsoluteNikola/ghc
  • cobrien99/ghc
  • songzh/ghc
  • blamario/ghc
  • aj4ayushjain/ghc
  • trac-utdemir/ghc
  • tangcl/ghc
  • hdgarrood/ghc
  • maerwald/ghc
  • arjun/ghc
  • ratherforky/ghc
  • haskieLambda/ghc
  • EmilGedda/ghc
  • Bogicevic/ghc
  • eddiejessup/ghc
  • kozross/ghc
  • AlistairB/ghc
  • 3Rafal/ghc
  • christiaanb/ghc
  • trac-bit/ghc
  • matsumonkie/ghc
  • trac-parsonsmatt/ghc
  • chisui/ghc
  • jaro/ghc
  • trac-kmiyazato/ghc
  • davidsd/ghc
  • Tritlo/ghc
  • I-B-3/ghc
  • lykahb/ghc
  • AriFordsham/ghc
  • turion1/ghc
  • berberman/ghc
  • christiantakle/ghc
  • zyklotomic/ghc
  • trac-ocramz/ghc
  • CSEdd/ghc
  • doyougnu/ghc
  • mmhat/ghc
  • why-not-try-calmer/ghc
  • plutotulp/ghc
  • kjekac/ghc
  • Manvi07/ghc
  • teo/ghc
  • cactus/ghc
  • CarrieMY/ghc
  • abel/ghc
  • yihming/ghc
  • tsakki/ghc
  • jessicah/ghc
  • oliverbunting/ghc
  • meld/ghc
  • friedbrice/ghc
  • Joald/ghc
  • abarbu/ghc
  • DigitalBrains1/ghc
  • sterni/ghc
  • alexDarcy/ghc
  • hexchain/ghc
  • minimario/ghc
  • zliu41/ghc
  • tommd/ghc
  • jazcarate/ghc
  • peterbecich/ghc
  • alirezaghey/ghc
  • solomon/ghc
  • mikael.urankar/ghc
  • davjam/ghc
  • int-index/ghc
  • MorrowM/ghc
  • nrnrnr/ghc
  • Sonfamm/ghc-test-only
  • afzt1/ghc
  • nguyenhaibinh-tpc/ghc
  • trac-lierdakil/ghc
  • MichaWiedenmann1/ghc
  • jmorag/ghc
  • Ziharrk/ghc
  • trac-MitchellSalad/ghc
  • juampe/ghc
  • jwaldmann/ghc
  • snowleopard/ghc
  • juhp/ghc
  • normalcoder/ghc
  • ksqsf/ghc
  • trac-jberryman/ghc
  • roberth/ghc
  • 1ntEgr8/ghc
  • epworth/ghc
  • MrAdityaAlok/ghc
  • JunmingZhao42/ghc
  • jappeace/ghc
  • trac-Gabriel439/ghc
  • alt-romes/ghc
  • HugoPeters1024/ghc
  • 10ne1/ghc-fork
  • agentultra/ghc
  • Garfield1002/ghc
  • ChickenProp/ghc
  • clyring/ghc
  • MaxHearnden/ghc
  • jumper149/ghc
  • vem/ghc
  • ketzacoatl/ghc
  • Rosuavio/ghc
  • jackohughes/ghc
  • p4l1ly/ghc
  • konsumlamm/ghc
  • shlevy/ghc
  • torsten.schmits/ghc
  • andremarianiello/ghc
  • amesgen/ghc
  • googleson78/ghc
  • InfiniteVerma/ghc
  • uhbif19/ghc
  • yiyunliu/ghc
  • raehik/ghc
  • mrkun/ghc
  • telser/ghc
  • 1Jajen1/ghc
  • slotThe/ghc
  • WinstonHartnett/ghc
  • mpilgrem/ghc
  • dreamsmasher/ghc
  • schuelermine/ghc
  • trac-Viwor/ghc
  • undergroundquizscene/ghc
  • evertedsphere/ghc
  • coltenwebb/ghc
  • oberblastmeister/ghc
  • agrue/ghc
  • lf-/ghc
  • zacwood9/ghc
  • steshaw/ghc
  • high-cloud/ghc
  • SkamDart/ghc
  • PiDelport/ghc
  • maoif/ghc
  • RossPaterson/ghc
  • CharlesTaylor7/ghc
  • ribosomerocker/ghc
  • trac-ramirez7/ghc
  • daig/ghc
  • NicolasT/ghc
  • FinleyMcIlwaine/ghc
  • lawtonnichols/ghc
  • jmtd/ghc
  • ozkutuk/ghc
  • wildsebastian/ghc
  • nikshalark/ghc
  • lrzlin/ghc
  • tobias/ghc
  • fw/ghc
  • hawkinsw/ghc
  • type-dance/ghc
  • rui314/ghc
  • ocharles/ghc
  • wavewave/ghc
  • TheKK/ghc
  • nomeata/ghc
  • trac-csabahruska/ghc
  • jonathanjameswatson/ghc
  • L-as/ghc
  • Axman6/ghc
  • barracuda156/ghc
  • trac-jship/ghc
  • jake-87/ghc
  • meooow/ghc
  • rebeccat/ghc
  • hamana55/ghc
  • Enigmage/ghc
  • kokobd/ghc
  • agevelt/ghc
  • gshen42/ghc
  • chrismwendt/ghc
  • MangoIV/ghc
  • teto/ghc
  • Sookr1/ghc
  • trac-thomasjm/ghc
  • barci2/ghc-dev
  • trac-m4dc4p/ghc
  • dixonary/ghc
  • breakerzirconia/ghc
  • alexsio27444/ghc
  • glocq/ghc
  • sourabhxyz/ghc
  • ryantrinkle/ghc
  • Jade/ghc
  • scedfaliako/ghc
  • martijnbastiaan/ghc
  • trac-george.colpitts/ghc
  • ammarbinfaisal/ghc
  • mimi.vx/ghc
  • lortabac/ghc
  • trac-zyla/ghc
  • benbellick/ghc
  • aadaa-fgtaa/ghc
  • jvanbruegge/ghc
  • archbung/ghc
  • gilmi/ghc
  • mfonism/ghc
  • alex-mckenna/ghc
  • Ei30metry/ghc
  • DiegoDiverio/ghc
  • jorgecunhamendes/ghc
  • liesnikov/ghc
  • akrmn/ghc
  • trac-simplifierticks/ghc
  • jacco/ghc
  • rhendric/ghc
  • damhiya/ghc
  • ryndubei/ghc
  • DaveBarton/ghc
  • trac-Profpatsch/ghc
  • GZGavinZhao/ghc
  • ncfavier/ghc
  • jameshaydon/ghc
  • ajccosta/ghc
  • dschrempf/ghc
  • cydparser/ghc
  • LinuxUserGD/ghc
  • elodielander/ghc
  • facundominguez/ghc
  • psilospore/ghc
  • lachrimae/ghc
  • dylan-thinnes/ghc-type-errors-plugin
  • hamishmack/ghc
  • Leary/ghc
  • lzszt/ghc
  • lyokha/ghc
  • trac-glaubitz/ghc
  • Rewbert/ghc
  • andreabedini/ghc
  • Jasagredo/ghc
  • sol/ghc
  • OlegAlexander/ghc
  • trac-sthibaul/ghc
  • avdv/ghc
  • Wendaolee/ghc
  • ur4t/ghc
  • daylily/ghc
  • boltzmannrain/ghc
  • mmzk1526/ghc
  • trac-fizzixnerd/ghc
  • soulomoon/ghc
  • rwmjones/ghc
  • j14i/ghc
  • tracsis/ghc
  • gesh/ghc
  • flip101/ghc
  • eldritch-cookie/ghc
  • LemonjamesD/ghc
  • pgujjula/ghc
  • skeuchel/ghc
  • noteed/ghc
  • gulin.serge/ghc
  • Torrekie/ghc
  • jlwoodwa/ghc
  • ayanamists/ghc
  • husong998/ghc
  • trac-edmundnoble/ghc
  • josephf/ghc
  • contrun/ghc
  • baulig/ghc
  • edsko/ghc
  • mzschr/ghc-issue-24732
  • ulidtko/ghc
  • Arsen/ghc
  • trac-sjoerd_visscher/ghc
  • crumbtoo/ghc
  • L0neGamer/ghc
  • DrewFenwick/ghc
  • benz0li/ghc
  • MaciejWas/ghc
  • jordanrule/ghc
  • trac-qqwy/ghc
  • LiamGoodacre/ghc
  • isomorpheme/ghc
  • trac-danidiaz/ghc
  • Kariim/ghc
  • MTaimoorZaeem/ghc
  • hololeap/ghc
  • ticat-fp/ghc
  • meritamen/ghc
  • criskell/ghc
  • trac-kraai/ghc
  • aergus/ghc
  • jdral/ghc
  • SamB/ghc
  • Tristian/ghc
  • ywgrit/ghc
  • KatsuPatrick/ghc
  • OsePedro/ghc
  • mpscholten/ghc
  • fp/ghc
  • zaquest/ghc
  • fangyi-zhou/ghc
  • augyg/ghc
640 results
Show changes
Showing
with 219 additions and 214 deletions
...@@ -1058,7 +1058,7 @@ tcPatSynPat (L con_span con_name) pat_syn pat_ty penv arg_pats thing_inside ...@@ -1058,7 +1058,7 @@ tcPatSynPat (L con_span con_name) pat_syn pat_ty penv arg_pats thing_inside
-- 'tcDataConPat'.) -- 'tcDataConPat'.)
; let ; let
bad_arg_tys :: [(Int, Scaled Type)] bad_arg_tys :: [(Int, Scaled Type)]
bad_arg_tys = filter (\ (_, Scaled _ arg_ty) -> typeLevity_maybe arg_ty == Nothing) bad_arg_tys = filter (\ (_, Scaled _ arg_ty) -> not (typeHasFixedRuntimeRep arg_ty))
$ zip [0..] arg_tys' $ zip [0..] arg_tys'
; massertPpr (null bad_arg_tys) $ ; massertPpr (null bad_arg_tys) $
vcat [ text "tcPatSynPat: pattern arguments do not have a fixed RuntimeRep" vcat [ text "tcPatSynPat: pattern arguments do not have a fixed RuntimeRep"
......
...@@ -527,7 +527,7 @@ also know `t2` and the other way. ...@@ -527,7 +527,7 @@ also know `t2` and the other way.
closeWrtFunDeps is used closeWrtFunDeps is used
- when checking the coverage condition for an instance declaration - when checking the coverage condition for an instance declaration
- when determining which tyvars are unquantifiable during generalization, in - when determining which tyvars are unquantifiable during generalization, in
GHC.Tc.Solver.decideMonoTyVars. GHC.Tc.Solver.decidePromotedTyVars.
Note [Equality superclasses] Note [Equality superclasses]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
...@@ -169,7 +169,6 @@ import GHC.Core.Reduction ...@@ -169,7 +169,6 @@ import GHC.Core.Reduction
import GHC.Core.Class import GHC.Core.Class
import GHC.Core.TyCon import GHC.Core.TyCon
import GHC.Types.Error ( mkPlainError, noHints )
import GHC.Types.Name import GHC.Types.Name
import GHC.Types.TyThing import GHC.Types.TyThing
import GHC.Types.Name.Reader import GHC.Types.Name.Reader
...@@ -1886,19 +1885,10 @@ solverDepthError loc ty ...@@ -1886,19 +1885,10 @@ solverDepthError loc ty
; return (ty, env0) } ; return (ty, env0) }
; let tidy_env = tidyFreeTyCoVars env0 (tyCoVarsOfTypeList ty) ; let tidy_env = tidyFreeTyCoVars env0 (tyCoVarsOfTypeList ty)
tidy_ty = tidyType tidy_env ty tidy_ty = tidyType tidy_env ty
msg = mkTcRnUnknownMessage $ mkPlainError noHints $ msg = TcRnSolverDepthError tidy_ty depth
vcat [ text "Reduction stack overflow; size =" <+> ppr depth
, hang (text "When simplifying the following type:")
2 (ppr tidy_ty)
, note ]
; TcM.failWithTcM (tidy_env, msg) } ; TcM.failWithTcM (tidy_env, msg) }
where where
depth = ctLocDepth loc depth = ctLocDepth loc
note = vcat
[ text "Use -freduction-depth=0 to disable this check"
, text "(any upper bound you could choose might fail unpredictably with"
, text " minor updates to GHC, so disabling the check is recommended if"
, text " you're sure that type checking should terminate)" ]
{- {-
************************************************************************ ************************************************************************
......
...@@ -34,13 +34,7 @@ import GHC.Driver.Config.HsToCore ...@@ -34,13 +34,7 @@ import GHC.Driver.Config.HsToCore
import GHC.Hs import GHC.Hs
import GHC.Tc.Errors.Types ( TcRnMessage(..), FixedRuntimeRepProvenance(..) import GHC.Tc.Errors.Types
, IllegalNewtypeReason (..)
, UninferrableTyVarCtx (..)
, BadFieldAnnotationReason (..)
, RoleValidationFailedReason (..)
, DisabledClassExtension (..)
, TyFamsDisabledReason (..) )
import GHC.Tc.TyCl.Build import GHC.Tc.TyCl.Build
import GHC.Tc.Solver( pushLevelAndSolveEqualities, pushLevelAndSolveEqualitiesX import GHC.Tc.Solver( pushLevelAndSolveEqualities, pushLevelAndSolveEqualitiesX
, reportUnsolvedEqualities ) , reportUnsolvedEqualities )
...@@ -2690,7 +2684,10 @@ tcClassATs :: Name -- The class name (not knot-tied) ...@@ -2690,7 +2684,10 @@ tcClassATs :: Name -- The class name (not knot-tied)
-> TcM [ClassATItem] -> TcM [ClassATItem]
tcClassATs class_name cls ats at_defs tcClassATs class_name cls ats at_defs
= do { -- Complain about associated type defaults for non associated-types = do { -- Complain about associated type defaults for non associated-types
sequence_ [ failWithTc (TcRnBadAssociatedType class_name n) sequence_ [ failWithTc $ TcRnIllegalInstance
$ IllegalFamilyInstance $ InvalidAssoc
$ InvalidAssocDefault
$ AssocDefaultNotAssoc class_name n
| n <- map at_def_tycon at_defs | n <- map at_def_tycon at_defs
, not (n `elemNameSet` at_names) ] , not (n `elemNameSet` at_names) ]
; mapM tc_at ats } ; mapM tc_at ats }
...@@ -2724,7 +2721,9 @@ tcDefaultAssocDecl _ [] ...@@ -2724,7 +2721,9 @@ tcDefaultAssocDecl _ []
= return Nothing -- No default declaration = return Nothing -- No default declaration
tcDefaultAssocDecl _ (d1:_:_) tcDefaultAssocDecl _ (d1:_:_)
= failWithTc (TcRnMultiAssocTyFamDefaults (tyFamInstDeclName (unLoc d1))) = failWithTc $ TcRnIllegalInstance $ IllegalFamilyInstance
$ InvalidAssoc $ InvalidAssocDefault $
AssocMultipleDefaults (tyFamInstDeclName (unLoc d1))
tcDefaultAssocDecl fam_tc tcDefaultAssocDecl fam_tc
[L loc (TyFamInstDecl { tfid_eqn = [L loc (TyFamInstDecl { tfid_eqn =
...@@ -2742,11 +2741,14 @@ tcDefaultAssocDecl fam_tc ...@@ -2742,11 +2741,14 @@ tcDefaultAssocDecl fam_tc
-- Kind of family check -- Kind of family check
; assert (fam_tc_name == tc_name) $ ; assert (fam_tc_name == tc_name) $
checkTc (isTypeFamilyTyCon fam_tc) (TcRnFamilyCategoryMismatch fam_tc) checkTc (isTypeFamilyTyCon fam_tc) $
TcRnIllegalInstance $ IllegalFamilyInstance $
FamilyCategoryMismatch fam_tc
-- Arity check -- Arity check
; checkTc (vis_pats == vis_arity) ; checkTc (vis_pats == vis_arity) $
(TcRnFamilyArityMismatch fam_tc vis_arity) TcRnIllegalInstance $ IllegalFamilyInstance $
FamilyArityMismatch fam_tc vis_arity
-- Typecheck RHS -- Typecheck RHS
-- --
...@@ -3215,7 +3217,8 @@ checkTyFamInstEqn tc_fam_tc eqn_tc_name hs_pats = ...@@ -3215,7 +3217,8 @@ checkTyFamInstEqn tc_fam_tc eqn_tc_name hs_pats =
-- type family F a where { G Int = Bool } -- type family F a where { G Int = Bool }
let tc_fam_tc_name = getName tc_fam_tc let tc_fam_tc_name = getName tc_fam_tc
; checkTc (tc_fam_tc_name == eqn_tc_name) $ ; checkTc (tc_fam_tc_name == eqn_tc_name) $
TcRnTyFamNameMismatch tc_fam_tc_name eqn_tc_name TcRnIllegalInstance $ IllegalFamilyInstance $
TyFamNameMismatch tc_fam_tc_name eqn_tc_name
-- Check the arity of visible arguments -- Check the arity of visible arguments
-- If we wait until validity checking, we'll get kind errors -- If we wait until validity checking, we'll get kind errors
...@@ -3223,7 +3226,8 @@ checkTyFamInstEqn tc_fam_tc eqn_tc_name hs_pats = ...@@ -3223,7 +3226,8 @@ checkTyFamInstEqn tc_fam_tc eqn_tc_name hs_pats =
; let vis_arity = length (tyConVisibleTyVars tc_fam_tc) ; let vis_arity = length (tyConVisibleTyVars tc_fam_tc)
vis_pats = numVisibleArgs hs_pats vis_pats = numVisibleArgs hs_pats
; checkTc (vis_pats == vis_arity) $ ; checkTc (vis_pats == vis_arity) $
TcRnFamilyArityMismatch tc_fam_tc vis_arity TcRnIllegalInstance $ IllegalFamilyInstance $
FamilyArityMismatch tc_fam_tc vis_arity
} }
{- Note [Instantiating a family tycon] {- Note [Instantiating a family tycon]
...@@ -4823,8 +4827,10 @@ checkValidClass cls ...@@ -4823,8 +4827,10 @@ checkValidClass cls
check_at (ATI fam_tc m_dflt_rhs) check_at (ATI fam_tc m_dflt_rhs)
= do { traceTc "ati" (ppr fam_tc $$ ppr tyvars $$ ppr fam_tvs) = do { traceTc "ati" (ppr fam_tc $$ ppr tyvars $$ ppr fam_tvs)
; checkTc (cls_arity == 0 || any (`elemVarSet` cls_tv_set) fam_tvs) ; checkTc (cls_arity == 0 || any (`elemVarSet` cls_tv_set) fam_tvs) $
(TcRnAssocNoClassTyVar cls fam_tc) TcRnIllegalInstance $ IllegalFamilyInstance $
InvalidAssoc $ InvalidAssocInstance $
AssocNoClassTyVar cls fam_tc
-- Check that the associated type mentions at least -- Check that the associated type mentions at least
-- one of the class type variables -- one of the class type variables
-- The check is disabled for nullary type classes, -- The check is disabled for nullary type classes,
......
...@@ -601,6 +601,8 @@ warnMissingAT name ...@@ -601,6 +601,8 @@ warnMissingAT name
-- hs-boot and signatures never need to provide complete "definitions" -- hs-boot and signatures never need to provide complete "definitions"
-- of any sort, as they aren't really defining anything, but just -- of any sort, as they aren't really defining anything, but just
-- constraining items which are defined elsewhere. -- constraining items which are defined elsewhere.
; let dia = TcRnNoExplicitAssocTypeOrDefaultDeclaration name ; let diag = TcRnIllegalInstance $ IllegalFamilyInstance
; diagnosticTc (warn && hsc_src == HsSrcFile) dia $ InvalidAssoc $ InvalidAssocInstance
$ AssocInstanceMissing name
; diagnosticTc (warn && hsc_src == HsSrcFile) diag
} }
...@@ -594,11 +594,15 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn })) ...@@ -594,11 +594,15 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn }))
tcAddTyFamInstCtxt decl $ tcAddTyFamInstCtxt decl $
do { let fam_lname = feqn_tycon eqn do { let fam_lname = feqn_tycon eqn
; fam_tc <- tcLookupLocatedTyCon fam_lname ; fam_tc <- tcLookupLocatedTyCon fam_lname
; tcFamInstDeclChecks mb_clsinfo fam_tc ; tcFamInstDeclChecks mb_clsinfo IAmType fam_tc
-- (0) Check it's an open type family -- (0) Check it's an open type family
; checkTc (isTypeFamilyTyCon fam_tc) (TcRnFamilyCategoryMismatch fam_tc) ; checkTc (isTypeFamilyTyCon fam_tc) $
; checkTc (isOpenTypeFamilyTyCon fam_tc) (TcRnNotOpenFamily fam_tc) TcRnIllegalInstance $ IllegalFamilyInstance $
FamilyCategoryMismatch fam_tc
; checkTc (isOpenTypeFamilyTyCon fam_tc) $
TcRnIllegalInstance $ IllegalFamilyInstance $
NotAnOpenFamilyTyCon fam_tc
-- (1) do the work of verifying the synonym group -- (1) do the work of verifying the synonym group
-- For some reason we don't have a location for the equation -- For some reason we don't have a location for the equation
...@@ -617,9 +621,9 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn })) ...@@ -617,9 +621,9 @@ tcTyFamInstDecl mb_clsinfo (L loc decl@(TyFamInstDecl { tfid_eqn = eqn }))
--------------------- ---------------------
tcFamInstDeclChecks :: AssocInstInfo -> TyCon -> TcM () tcFamInstDeclChecks :: AssocInstInfo -> TypeOrData -> TyCon -> TcM ()
-- Used for both type and data families -- Used for both type and data families
tcFamInstDeclChecks mb_clsinfo fam_tc tcFamInstDeclChecks mb_clsinfo ty_or_data fam_tc
= do { -- Type family instances require -XTypeFamilies = do { -- Type family instances require -XTypeFamilies
-- and can't (currently) be in an hs-boot file -- and can't (currently) be in an hs-boot file
; traceTc "tcFamInstDecl" (ppr fam_tc) ; traceTc "tcFamInstDecl" (ppr fam_tc)
...@@ -632,13 +636,17 @@ tcFamInstDeclChecks mb_clsinfo fam_tc ...@@ -632,13 +636,17 @@ tcFamInstDeclChecks mb_clsinfo fam_tc
HsSrcFile -> HsSrcFile ->
return () return ()
-- Check that it is a family TyCon, and that -- Check that it is a family TyCon
-- oplevel type instances are not for associated types. ; checkTc (isFamilyTyCon fam_tc) $
; checkTc (isFamilyTyCon fam_tc) (TcRnIllegalFamilyInstance fam_tc) TcRnIllegalInstance $ IllegalFamilyInstance $
NotAFamilyTyCon ty_or_data fam_tc
-- Check that top-level type instances are not for associated types.
; when (isNotAssociated mb_clsinfo && -- Not in a class decl ; when (isNotAssociated mb_clsinfo && -- Not in a class decl
isTyConAssoc fam_tc) -- but an associated type isTyConAssoc fam_tc) $ -- but an associated type
(addErr $ TcRnMissingClassAssoc fam_tc) addErr $ TcRnIllegalInstance $ IllegalFamilyInstance
$ InvalidAssoc $ InvalidAssocInstance
$ AssocInstanceNotInAClass fam_tc
} }
{- Note [Associated type instances] {- Note [Associated type instances]
...@@ -693,10 +701,12 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env ...@@ -693,10 +701,12 @@ tcDataFamInstDecl mb_clsinfo tv_skol_env
tcAddDataFamInstCtxt decl $ tcAddDataFamInstCtxt decl $
do { fam_tc <- tcLookupLocatedTyCon lfam_name do { fam_tc <- tcLookupLocatedTyCon lfam_name
; tcFamInstDeclChecks mb_clsinfo fam_tc ; tcFamInstDeclChecks mb_clsinfo IAmData fam_tc
-- Check that the family declaration is for the right kind -- Check that the family declaration is for the right kind
; checkTc (isDataFamilyTyCon fam_tc) (TcRnFamilyCategoryMismatch fam_tc) ; checkTc (isDataFamilyTyCon fam_tc) $
TcRnIllegalInstance $ IllegalFamilyInstance $
FamilyCategoryMismatch fam_tc
; gadt_syntax <- dataDeclChecks fam_name hs_ctxt hs_cons ; gadt_syntax <- dataDeclChecks fam_name hs_ctxt hs_cons
-- Do /not/ check that the number of patterns = tyConArity fam_tc -- Do /not/ check that the number of patterns = tyConArity fam_tc
-- See [Arity of data families] in GHC.Core.FamInstEnv -- See [Arity of data families] in GHC.Core.FamInstEnv
......
...@@ -1717,7 +1717,7 @@ we leave it alone. ...@@ -1717,7 +1717,7 @@ we leave it alone.
Note that not *every* variable with a higher level will get Note that not *every* variable with a higher level will get
generalised, either due to the monomorphism restriction or other generalised, either due to the monomorphism restriction or other
quirks. See, for example, the code in GHC.Tc.Solver.decideMonoTyVars quirks. See, for example, the code in GHC.Tc.Solver.decidePromotedTyVars
and in GHC.Tc.Gen.HsType.kindGeneralizeSome, both of which exclude and in GHC.Tc.Gen.HsType.kindGeneralizeSome, both of which exclude
certain otherwise-eligible variables from being generalised. certain otherwise-eligible variables from being generalised.
......
...@@ -2001,8 +2001,8 @@ being the ) ...@@ -2001,8 +2001,8 @@ being the )
-} -}
tcSplitIOType_maybe :: Type -> Maybe (TyCon, Type) tcSplitIOType_maybe :: Type -> Maybe (TyCon, Type)
-- (tcSplitIOType_maybe t) returns Just (IO,t',co) -- (tcSplitIOType_maybe t) returns Just (IO,t')
-- if co : t ~ IO t' -- if t = IO t'
-- returns Nothing otherwise -- returns Nothing otherwise
tcSplitIOType_maybe ty tcSplitIOType_maybe ty
= case tcSplitTyConApp_maybe ty of = case tcSplitTyConApp_maybe ty of
......
...@@ -53,8 +53,6 @@ import GHC.Core.TyCo.Ppr ...@@ -53,8 +53,6 @@ import GHC.Core.TyCo.Ppr
import GHC.Core.FamInstEnv ( isDominatedBy, injectiveBranches import GHC.Core.FamInstEnv ( isDominatedBy, injectiveBranches
, InjectivityCheckResult(..) ) , InjectivityCheckResult(..) )
import GHC.Iface.Type ( pprIfaceType, pprIfaceTypeApp )
import GHC.CoreToIface ( toIfaceTyCon, toIfaceTcArgs, toIfaceType )
import GHC.Hs import GHC.Hs
import GHC.Driver.Session import GHC.Driver.Session
import qualified GHC.LanguageExtensions as LangExt import qualified GHC.LanguageExtensions as LangExt
...@@ -64,7 +62,7 @@ import GHC.Types.Basic ( UnboxedTupleOrSum(..), unboxedTupleOrSumExtension ) ...@@ -64,7 +62,7 @@ import GHC.Types.Basic ( UnboxedTupleOrSum(..), unboxedTupleOrSumExtension )
import GHC.Types.Name import GHC.Types.Name
import GHC.Types.Var.Env import GHC.Types.Var.Env
import GHC.Types.Var.Set import GHC.Types.Var.Set
import GHC.Types.Var ( VarBndr(..), isInvisibleFunArg, mkTyVar ) import GHC.Types.Var ( VarBndr(..), isInvisibleFunArg, mkTyVar, tyVarName )
import GHC.Types.SourceFile import GHC.Types.SourceFile
import GHC.Types.SrcLoc import GHC.Types.SrcLoc
import GHC.Types.TyThing ( TyThing(..) ) import GHC.Types.TyThing ( TyThing(..) )
...@@ -84,7 +82,6 @@ import Control.Monad ...@@ -84,7 +82,6 @@ import Control.Monad
import Data.Foldable import Data.Foldable
import Data.Function import Data.Function
import Data.List ( (\\) ) import Data.List ( (\\) )
import qualified Data.List.NonEmpty as NE
{- {-
************************************************************************ ************************************************************************
...@@ -1454,7 +1451,8 @@ check_special_inst_head dflags hs_src ctxt clas cls_args ...@@ -1454,7 +1451,8 @@ check_special_inst_head dflags hs_src ctxt clas cls_args
-- Abstract classes cannot have instances, except in hs-boot or signature files. -- Abstract classes cannot have instances, except in hs-boot or signature files.
| isAbstractClass clas | isAbstractClass clas
, hs_src == HsSrcFile , hs_src == HsSrcFile
= failWithTc (TcRnAbstractClassInst clas) = fail_with_inst_err $ IllegalInstanceHead
$ InstHeadAbstractClass clas
-- Complain about hand-written instances of built-in classes -- Complain about hand-written instances of built-in classes
-- Typeable, KnownNat, KnownSymbol, Coercible, HasField. -- Typeable, KnownNat, KnownSymbol, Coercible, HasField.
...@@ -1466,7 +1464,7 @@ check_special_inst_head dflags hs_src ctxt clas cls_args ...@@ -1466,7 +1464,7 @@ check_special_inst_head dflags hs_src ctxt clas cls_args
, not (hs_src == HsigFile) , not (hs_src == HsigFile)
-- Note [Instances of built-in classes in signature files] -- Note [Instances of built-in classes in signature files]
, hand_written_bindings , hand_written_bindings
= failWithTc $ TcRnSpecialClassInst clas False = fail_with_inst_err $ IllegalSpecialClassInstance clas False
-- Handwritten instances of KnownNat/KnownChar/KnownSymbol -- Handwritten instances of KnownNat/KnownChar/KnownSymbol
-- are forbidden outside of signature files (#12837). -- are forbidden outside of signature files (#12837).
...@@ -1474,7 +1472,7 @@ check_special_inst_head dflags hs_src ctxt clas cls_args ...@@ -1474,7 +1472,7 @@ check_special_inst_head dflags hs_src ctxt clas cls_args
| clas_nm `elem` [ knownNatClassName, knownSymbolClassName, knownCharClassName ] | clas_nm `elem` [ knownNatClassName, knownSymbolClassName, knownCharClassName ]
, (not (hs_src == HsigFile) && hand_written_bindings) || derived_instance , (not (hs_src == HsigFile) && hand_written_bindings) || derived_instance
-- Note [Instances of built-in classes in signature files] -- Note [Instances of built-in classes in signature files]
= failWithTc $ TcRnSpecialClassInst clas False = fail_with_inst_err $ IllegalSpecialClassInstance clas False
-- For the most part we don't allow -- For the most part we don't allow
-- instances for (~), (~~), or Coercible; -- instances for (~), (~~), or Coercible;
...@@ -1484,12 +1482,13 @@ check_special_inst_head dflags hs_src ctxt clas cls_args ...@@ -1484,12 +1482,13 @@ check_special_inst_head dflags hs_src ctxt clas cls_args
[ heqTyConName, eqTyConName, coercibleTyConName [ heqTyConName, eqTyConName, coercibleTyConName
, withDictClassName, unsatisfiableClassName ] , withDictClassName, unsatisfiableClassName ]
, not quantified_constraint , not quantified_constraint
= failWithTc $ TcRnSpecialClassInst clas False = fail_with_inst_err $ IllegalSpecialClassInstance clas False
-- Check for hand-written Generic instances (disallowed in Safe Haskell) -- Check for hand-written Generic instances (disallowed in Safe Haskell)
| clas_nm `elem` genericClassNames | clas_nm `elem` genericClassNames
, hand_written_bindings , hand_written_bindings
= do { failIfTc (safeLanguageOn dflags) (TcRnSpecialClassInst clas True) = do { when (safeLanguageOn dflags) $
fail_with_inst_err $ IllegalSpecialClassInstance clas True
; when (safeInferOn dflags) (recordUnsafeInfer emptyMessages) } ; when (safeInferOn dflags) (recordUnsafeInfer emptyMessages) }
| clas_nm == hasFieldClassName | clas_nm == hasFieldClassName
...@@ -1504,12 +1503,19 @@ check_special_inst_head dflags hs_src ctxt clas cls_args ...@@ -1504,12 +1503,19 @@ check_special_inst_head dflags hs_src ctxt clas cls_args
-- Check language restrictions on the args to the class -- Check language restrictions on the args to the class
| check_h98_arg_shape | check_h98_arg_shape
, Just illegalType <- mb_ty_args_type , Just illegal_head <- mb_ty_args_type
= failWithTc (TcRnIllegalInstanceDecl clas cls_args illegalType) = fail_with_inst_err $ IllegalInstanceHead illegal_head
| otherwise | otherwise
= pure () = pure ()
where where
fail_with_inst_err err =
failWithTc $ TcRnIllegalInstance
$ IllegalClassInstance
(TypeThing $ mkClassPred clas cls_args)
$ err
clas_nm = getName clas clas_nm = getName clas
ty_args = filterOutInvisibleTypes (classTyCon clas) cls_args ty_args = filterOutInvisibleTypes (classTyCon clas) cls_args
...@@ -1546,16 +1552,16 @@ check_special_inst_head dflags hs_src ctxt clas cls_args ...@@ -1546,16 +1552,16 @@ check_special_inst_head dflags hs_src ctxt clas cls_args
mb_ty_args_type mb_ty_args_type
| not (xopt LangExt.TypeSynonymInstances dflags) | not (xopt LangExt.TypeSynonymInstances dflags)
, not (all tcInstHeadTyNotSynonym ty_args) , not (all tcInstHeadTyNotSynonym ty_args)
= Just IllegalInstanceHeadTypeSynonym = Just InstHeadTySynArgs
| not (xopt LangExt.FlexibleInstances dflags) | not (xopt LangExt.FlexibleInstances dflags)
, not (all tcInstHeadTyAppAllTyVars ty_args) , not (all tcInstHeadTyAppAllTyVars ty_args)
= Just IllegalInstanceHeadNonTyVarArgs = Just InstHeadNonTyVarArgs
| length ty_args /= 1 | length ty_args /= 1
, not (xopt LangExt.MultiParamTypeClasses dflags) , not (xopt LangExt.MultiParamTypeClasses dflags)
, not (xopt LangExt.NullaryTypeClasses dflags && null ty_args) , not (xopt LangExt.NullaryTypeClasses dflags && null ty_args)
= Just IllegalMultiParamInstance = Just InstHeadMultiParam
| otherwise | otherwise
= Nothing = Nothing
...@@ -1639,7 +1645,9 @@ checkHasFieldInst cls tys@[_k_ty, lbl_ty, r_ty, _a_ty] = ...@@ -1639,7 +1645,9 @@ checkHasFieldInst cls tys@[_k_ty, lbl_ty, r_ty, _a_ty] =
| otherwise | otherwise
-> add_err $ IllegalHasFieldInstanceTyConHasFields tc lbl_ty -> add_err $ IllegalHasFieldInstanceTyConHasFields tc lbl_ty
where where
add_err err = addErrTc $ TcRnIllegalInstanceDecl cls tys add_err err = addErrTc $ TcRnIllegalInstance
$ IllegalClassInstance
(TypeThing $ mkClassPred cls tys)
$ IllegalHasFieldInstance err $ IllegalHasFieldInstance err
checkHasFieldInst _ tys = pprPanic "checkHasFieldInst" (ppr tys) checkHasFieldInst _ tys = pprPanic "checkHasFieldInst" (ppr tys)
...@@ -1946,9 +1954,9 @@ if we find a constraint tuple. ...@@ -1946,9 +1954,9 @@ if we find a constraint tuple.
checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM () checkValidInstance :: UserTypeCtxt -> LHsSigType GhcRn -> Type -> TcM ()
checkValidInstance ctxt hs_type ty = case tau of checkValidInstance ctxt hs_type ty = case tau of
-- See Note [Instances and constraint synonyms] -- See Note [Instances and constraint synonyms]
TyConApp tc inst_tys -> case tyConClass_maybe tc of TyConApp tc inst_tys
Nothing -> failWithTc (TcRnIllegalClassInst (tyConFlavour tc)) | Just clas <- tyConClass_maybe tc
Just clas -> do -> do
{ setSrcSpanA head_loc $ { setSrcSpanA head_loc $
checkValidInstHead ctxt clas inst_tys checkValidInstHead ctxt clas inst_tys
...@@ -1979,16 +1987,21 @@ checkValidInstance ctxt hs_type ty = case tau of ...@@ -1979,16 +1987,21 @@ checkValidInstance ctxt hs_type ty = case tau of
IsValid IsValid
-> return () -- Check succeeded -> return () -- Check succeeded
NotValid coverageInstErr NotValid coverageInstErr
-> addErrTc $ TcRnIllegalInstanceDecl clas inst_tys -> addErrTc $ mk_err
$ IllegalInstanceFailsCoverageCondition coverageInstErr $ IllegalInstanceFailsCoverageCondition clas coverageInstErr
; traceTc "End checkValidInstance }" empty ; traceTc "End checkValidInstance }" empty }
| otherwise
; return () } -> failWithTc $ mk_err $ IllegalInstanceHead
_ -> failWithTc (TcRnNoClassInstHead tau) $ InstHeadNonClass (Just tc)
_ -> failWithTc $ mk_err $ IllegalInstanceHead
$ InstHeadNonClass Nothing
where where
(theta, tau) = splitInstTyForValidity ty (theta, tau) = splitInstTyForValidity ty
mk_err err = TcRnIllegalInstance
$ IllegalClassInstance (TypeThing tau) err
-- The location of the "head" of the instance -- The location of the "head" of the instance
head_loc = getLoc (getLHsInstDeclHead hs_type) head_loc = getLoc (getLHsInstDeclHead hs_type)
...@@ -2222,10 +2235,11 @@ checkValidAssocTyFamDeflt fam_tc pats = ...@@ -2222,10 +2235,11 @@ checkValidAssocTyFamDeflt fam_tc pats =
extract_tv pat pat_vis = extract_tv pat pat_vis =
case getTyVar_maybe pat of case getTyVar_maybe pat of
Just tv -> pure tv Just tv -> pure tv
Nothing -> failWithTc $ mkTcRnUnknownMessage $ mkPlainError noHints $ Nothing -> failWithTc $ TcRnIllegalInstance
pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ $ IllegalFamilyInstance
hang (text "Illegal argument" <+> quotes (ppr pat) <+> text "in:") $ InvalidAssoc $ InvalidAssocDefault
2 (vcat [ppr_eqn, suggestion]) $ AssocDefaultBadArgs fam_tc pats
$ AssocDefaultNonTyVarArg (pat, pat_vis)
-- Checks that no type variables in an associated default declaration are -- Checks that no type variables in an associated default declaration are
-- duplicated. If that is the case, throw an error. -- duplicated. If that is the case, throw an error.
...@@ -2239,23 +2253,13 @@ checkValidAssocTyFamDeflt fam_tc pats = ...@@ -2239,23 +2253,13 @@ checkValidAssocTyFamDeflt fam_tc pats =
check_all_distinct_tvs cpt_tvs_vis = check_all_distinct_tvs cpt_tvs_vis =
let dups = findDupsEq ((==) `on` fst) cpt_tvs_vis in let dups = findDupsEq ((==) `on` fst) cpt_tvs_vis in
traverse_ traverse_
(\d -> let (pat_tv, pat_vis) = NE.head d in failWithTc $ (\d -> failWithTc $ TcRnIllegalInstance
mkTcRnUnknownMessage $ mkPlainError noHints $ $ IllegalFamilyInstance
pprWithExplicitKindsWhen (isInvisibleForAllTyFlag pat_vis) $ $ InvalidAssoc $ InvalidAssocDefault
hang (text "Illegal duplicate variable" $ AssocDefaultBadArgs fam_tc pats
<+> quotes (ppr pat_tv) <+> text "in:") $ AssocDefaultDuplicateTyVars d)
2 (vcat [ppr_eqn, suggestion]))
dups dups
ppr_eqn :: SDoc
ppr_eqn =
quotes (text "type" <+> ppr (mkTyConApp fam_tc pats)
<+> equals <+> text "...")
suggestion :: SDoc
suggestion = text "The arguments to" <+> quotes (ppr fam_tc)
<+> text "must all be distinct type variables"
checkFamInstRhs :: TyCon -> [Type] -- LHS checkFamInstRhs :: TyCon -> [Type] -- LHS
-> [(TyCon, [Type])] -- type family calls in RHS -> [(TyCon, [Type])] -- type family calls in RHS
-> [TcRnMessage] -> [TcRnMessage]
...@@ -2300,15 +2304,14 @@ checkFamPatBinders fam_tc qtvs pats rhs ...@@ -2300,15 +2304,14 @@ checkFamPatBinders fam_tc qtvs pats rhs
-- In both cases, 'k' is not bound on the LHS, but is used on the RHS -- In both cases, 'k' is not bound on the LHS, but is used on the RHS
-- We catch the former in kcDeclHeader, and the latter right here -- We catch the former in kcDeclHeader, and the latter right here
-- See Note [Check type-family instance binders] -- See Note [Check type-family instance binders]
; check_tvs bad_rhs_tvs (text "mentioned in the RHS") ; check_tvs (FamInstRHSOutOfScopeTyVars (Just (fam_tc, pats, dodgy_tvs)))
(text "bound on the LHS of") bad_rhs_tvs
-- Check for explicitly forall'd variable that is not bound on LHS -- Check for explicitly forall'd variable that is not bound on LHS
-- data instance forall a. T Int = MkT Int -- data instance forall a. T Int = MkT Int
-- See Note [Unused explicitly bound variables in a family pattern] -- See Note [Unused explicitly bound variables in a family pattern]
-- See Note [Check type-family instance binders] -- See Note [Check type-family instance binders]
; check_tvs bad_qtvs (text "bound by a forall") ; check_tvs FamInstLHSUnusedBoundTyVars bad_qtvs
(text "used in")
} }
where where
cpt_tvs = tyCoVarsOfTypes pats cpt_tvs = tyCoVarsOfTypes pats
...@@ -2329,20 +2332,10 @@ checkFamPatBinders fam_tc qtvs pats rhs ...@@ -2329,20 +2332,10 @@ checkFamPatBinders fam_tc qtvs pats rhs
-- Used on RHS but not bound on LHS -- Used on RHS but not bound on LHS
dodgy_tvs = cpt_tvs `minusVarSet` inj_cpt_tvs dodgy_tvs = cpt_tvs `minusVarSet` inj_cpt_tvs
check_tvs tvs what what2 check_tvs mk_err tvs
= unless (null tvs) $ addErrAt (getSrcSpan (head tvs)) $ mkTcRnUnknownMessage $ mkPlainError noHints $ = unless (null tvs) $ addErrAt (getSrcSpan (head tvs)) $
hang (text "Type variable" <> plural tvs <+> pprQuotedList tvs TcRnIllegalInstance $ IllegalFamilyInstance $
<+> isOrAre tvs <+> what <> comma) mk_err (map tyVarName tvs)
2 (vcat [ text "but not" <+> what2 <+> text "the family instance"
, mk_extra tvs ])
-- mk_extra: #7536: give a decent error message for
-- type T a = Int
-- type instance F (T a) = a
mk_extra tvs = ppWhen (any (`elemVarSet` dodgy_tvs) tvs) $
hang (text "The real LHS (expanding synonyms) is:")
2 (pprTypeApp fam_tc (map expandTypeSynonyms pats))
-- | Checks that a list of type patterns is valid in a matching (LHS) -- | Checks that a list of type patterns is valid in a matching (LHS)
-- position of a class instances or type/data family instance. -- position of a class instances or type/data family instance.
...@@ -2361,19 +2354,13 @@ checkValidTypePats tc pat_ty_args ...@@ -2361,19 +2354,13 @@ checkValidTypePats tc pat_ty_args
-- Ensure that no type family applications occur a type pattern -- Ensure that no type family applications occur a type pattern
; case tcTyConAppTyFamInstsAndVis tc pat_ty_args of ; case tcTyConAppTyFamInstsAndVis tc pat_ty_args of
[] -> pure () [] -> pure ()
((tf_is_invis_arg, tf_tc, tf_args):_) -> failWithTc $ mkTcRnUnknownMessage $ mkPlainError noHints $ ((tf_is_invis_arg, tf_tc, tf_args):_) ->
ty_fam_inst_illegal_err tf_is_invis_arg failWithTc $ TcRnIllegalInstance $
(mkTyConApp tf_tc tf_args) } IllegalFamilyApplicationInInstance inst_ty
tf_is_invis_arg tf_tc tf_args }
where where
inst_ty = mkTyConApp tc pat_ty_args inst_ty = mkTyConApp tc pat_ty_args
ty_fam_inst_illegal_err :: Bool -> Type -> SDoc
ty_fam_inst_illegal_err invis_arg ty
= pprWithExplicitKindsWhen invis_arg $
hang (text "Illegal type synonym family application"
<+> quotes (ppr ty) <+> text "in instance" <> colon)
2 (ppr inst_ty)
------------------------- -------------------------
checkConsistentFamInst :: AssocInstInfo checkConsistentFamInst :: AssocInstInfo
-> TyCon -- ^ Family tycon -> TyCon -- ^ Family tycon
...@@ -2397,8 +2384,10 @@ checkConsistentFamInst (InClsInst { ai_class = clas ...@@ -2397,8 +2384,10 @@ checkConsistentFamInst (InClsInst { ai_class = clas
-- Check that the associated type indeed comes from this class -- Check that the associated type indeed comes from this class
-- See [Mismatched class methods and associated type families] -- See [Mismatched class methods and associated type families]
-- in TcInstDecls. -- in TcInstDecls.
; checkTc (Just (classTyCon clas) == tyConAssoc_maybe fam_tc) ; checkTc (Just (classTyCon clas) == tyConAssoc_maybe fam_tc) $
(TcRnBadAssociatedType (className clas) (tyConName fam_tc)) TcRnIllegalInstance $ IllegalFamilyInstance $
InvalidAssoc $ InvalidAssocInstance $
AssocNotInThisClass clas fam_tc
; check_match arg_triples ; check_match arg_triples
} }
...@@ -2413,29 +2402,12 @@ checkConsistentFamInst (InClsInst { ai_class = clas ...@@ -2413,29 +2402,12 @@ checkConsistentFamInst (InClsInst { ai_class = clas
ax_arg_tys ax_arg_tys
, Just cls_arg_ty <- [lookupVarEnv mini_env fam_tc_tv] ] , Just cls_arg_ty <- [lookupVarEnv mini_env fam_tc_tv] ]
pp_wrong_at_arg vis
= pprWithExplicitKindsWhen (isInvisibleForAllTyFlag vis) $
vcat [ text "Type indexes must match class instance head"
, text "Expected:" <+> pp_expected_ty
, text " Actual:" <+> pp_actual_ty ]
-- Fiddling around to arrange that wildcards unconditionally print as "_" -- Fiddling around to arrange that wildcards unconditionally print as "_"
-- We only need to print the LHS, not the RHS at all -- We only need to print the LHS, not the RHS at all
-- See Note [Printing conflicts with class header] -- See Note [Printing conflicts with class header]
(tidy_env1, _) = tidyVarBndrs emptyTidyEnv inst_tvs (tidy_env1, _) = tidyVarBndrs emptyTidyEnv inst_tvs
(tidy_env2, _) = tidyCoAxBndrsForUser tidy_env1 (ax_tvs \\ inst_tvs) (tidy_env2, _) = tidyCoAxBndrsForUser tidy_env1 (ax_tvs \\ inst_tvs)
pp_expected_ty = pprIfaceTypeApp topPrec (toIfaceTyCon fam_tc) $
toIfaceTcArgs fam_tc $
[ case lookupVarEnv mini_env at_tv of
Just cls_arg_ty -> tidyType tidy_env2 cls_arg_ty
Nothing -> mk_wildcard at_tv
| at_tv <- tyConTyVars fam_tc ]
pp_actual_ty = pprIfaceTypeApp topPrec (toIfaceTyCon fam_tc) $
toIfaceTcArgs fam_tc $
tidyTypes tidy_env2 ax_arg_tys
mk_wildcard at_tv = mkTyVarTy (mkTyVar tv_name (tyVarKind at_tv)) mk_wildcard at_tv = mkTyVarTy (mkTyVar tv_name (tyVarKind at_tv))
tv_name = mkInternalName (mkAlphaTyVarUnique 1) (mkTyVarOccFS (fsLit "_")) noSrcSpan tv_name = mkInternalName (mkAlphaTyVarUnique 1) (mkTyVarOccFS (fsLit "_")) noSrcSpan
...@@ -2450,7 +2422,17 @@ checkConsistentFamInst (InClsInst { ai_class = clas ...@@ -2450,7 +2422,17 @@ checkConsistentFamInst (InClsInst { ai_class = clas
, Just rl_subst1 <- tcMatchTyX_BM bind_me rl_subst ty2 ty1 , Just rl_subst1 <- tcMatchTyX_BM bind_me rl_subst ty2 ty1
= go lr_subst1 rl_subst1 triples = go lr_subst1 rl_subst1 triples
| otherwise | otherwise
= addErrTc (mkTcRnUnknownMessage $ mkPlainError noHints $ pp_wrong_at_arg vis) = addErrTc $ TcRnIllegalInstance $ IllegalFamilyInstance
$ InvalidAssoc $ InvalidAssocInstance
$ AssocTyVarsDontMatch vis fam_tc exp_tys act_tys
-- Expected/actual family argument types (for error messages)
exp_tys =
[ case lookupVarEnv mini_env at_tv of
Just cls_arg_ty -> tidyType tidy_env2 cls_arg_ty
Nothing -> mk_wildcard at_tv
| at_tv <- tyConTyVars fam_tc ]
act_tys = tidyTypes tidy_env2 ax_arg_tys
-- The /scoped/ type variables from the class-instance header -- The /scoped/ type variables from the class-instance header
-- should not be alpha-renamed. Inferred ones can be. -- should not be alpha-renamed. Inferred ones can be.
...@@ -2878,19 +2860,12 @@ checkTyConTelescope :: TyCon -> TcM () ...@@ -2878,19 +2860,12 @@ checkTyConTelescope :: TyCon -> TcM ()
checkTyConTelescope tc checkTyConTelescope tc
| bad_scope | bad_scope
= -- See "Ill-scoped binders" in Note [Bad TyCon telescopes] = -- See "Ill-scoped binders" in Note [Bad TyCon telescopes]
addErr $ mkTcRnUnknownMessage $ mkPlainError noHints $ addErr $ TcRnBadTyConTelescope tc
vcat [ hang (text "The kind of" <+> quotes (ppr tc) <+> text "is ill-scoped")
2 pp_tc_kind
, extra
, hang (text "Perhaps try this order instead:")
2 (pprTyVars sorted_tvs) ]
| otherwise | otherwise
= return () = return ()
where where
tcbs = tyConBinders tc tcbs = tyConBinders tc
tvs = binderVars tcbs
sorted_tvs = scopedSort tvs
(_, bad_scope) = foldl add_one (emptyVarSet, False) tcbs (_, bad_scope) = foldl add_one (emptyVarSet, False) tcbs
...@@ -2901,34 +2876,3 @@ checkTyConTelescope tc ...@@ -2901,34 +2876,3 @@ checkTyConTelescope tc
where where
tv = binderVar tcb tv = binderVar tcb
fkvs = tyCoVarsOfType (tyVarKind tv) fkvs = tyCoVarsOfType (tyVarKind tv)
inferred_tvs = [ binderVar tcb
| tcb <- tcbs, Inferred == tyConBinderForAllTyFlag tcb ]
specified_tvs = [ binderVar tcb
| tcb <- tcbs, Specified == tyConBinderForAllTyFlag tcb ]
pp_inf = parens (text "namely:" <+> pprTyVars inferred_tvs)
pp_spec = parens (text "namely:" <+> pprTyVars specified_tvs)
pp_tc_kind = text "Inferred kind:" <+> ppr tc <+> dcolon <+> ppr_untidy (tyConKind tc)
ppr_untidy ty = pprIfaceType (toIfaceType ty)
-- We need ppr_untidy here because pprType will tidy the type, which
-- will turn the bogus kind we are trying to report
-- T :: forall (a::k) k (b::k) -> blah
-- into a misleadingly sanitised version
-- T :: forall (a::k) k1 (b::k1) -> blah
extra
| null inferred_tvs && null specified_tvs
= empty
| null inferred_tvs
= hang (text "NB: Specified variables")
2 (sep [pp_spec, text "always come first"])
| null specified_tvs
= hang (text "NB: Inferred variables")
2 (sep [pp_inf, text "always come first"])
| otherwise
= hang (text "NB: Inferred variables")
2 (vcat [ sep [ pp_inf, text "always come first"]
, sep [text "then Specified variables", pp_spec]])
...@@ -1194,7 +1194,7 @@ zonk_cmd_top (HsCmdTop (CmdTopTc stack_tys ty ids) cmd) ...@@ -1194,7 +1194,7 @@ zonk_cmd_top (HsCmdTop (CmdTopTc stack_tys ty ids) cmd)
new_ty <- zonkTcTypeToTypeX ty new_ty <- zonkTcTypeToTypeX ty
new_ids <- mapSndM zonkExpr ids new_ids <- mapSndM zonkExpr ids
massert (isLiftedTypeKind (typeKind new_stack_tys)) massert (definitelyLiftedType new_stack_tys)
-- desugarer assumes that this is not representation-polymorphic... -- desugarer assumes that this is not representation-polymorphic...
-- but indeed it should always be lifted due to the typing -- but indeed it should always be lifted due to the typing
-- rules for arrows -- rules for arrows
......
...@@ -329,6 +329,7 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -329,6 +329,7 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "RepresentationalEq" = 10283 GhcDiagnosticCode "RepresentationalEq" = 10283
-- Typechecker/renamer diagnostic codes -- Typechecker/renamer diagnostic codes
GhcDiagnosticCode "TcRnSolverDepthError" = 40404
GhcDiagnosticCode "TcRnRedundantConstraints" = 30606 GhcDiagnosticCode "TcRnRedundantConstraints" = 30606
GhcDiagnosticCode "TcRnInaccessibleCode" = 40564 GhcDiagnosticCode "TcRnInaccessibleCode" = 40564
GhcDiagnosticCode "TcRnInaccessibleCoAxBranch" = 28129 GhcDiagnosticCode "TcRnInaccessibleCoAxBranch" = 28129
...@@ -371,8 +372,6 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -371,8 +372,6 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnPolymorphicBinderMissingSig" = 64414 GhcDiagnosticCode "TcRnPolymorphicBinderMissingSig" = 64414
GhcDiagnosticCode "TcRnOverloadedSig" = 16675 GhcDiagnosticCode "TcRnOverloadedSig" = 16675
GhcDiagnosticCode "TcRnTupleConstraintInst" = 69012 GhcDiagnosticCode "TcRnTupleConstraintInst" = 69012
GhcDiagnosticCode "TcRnAbstractClassInst" = 51758
GhcDiagnosticCode "TcRnNoClassInstHead" = 56538
GhcDiagnosticCode "TcRnUserTypeError" = 47403 GhcDiagnosticCode "TcRnUserTypeError" = 47403
GhcDiagnosticCode "TcRnConstraintInKind" = 01259 GhcDiagnosticCode "TcRnConstraintInKind" = 01259
GhcDiagnosticCode "TcRnUnboxedTupleOrSumTypeFuncArg" = 19590 GhcDiagnosticCode "TcRnUnboxedTupleOrSumTypeFuncArg" = 19590
...@@ -384,9 +383,7 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -384,9 +383,7 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnNonTypeVarArgInConstraint" = 80003 GhcDiagnosticCode "TcRnNonTypeVarArgInConstraint" = 80003
GhcDiagnosticCode "TcRnIllegalImplicitParam" = 75863 GhcDiagnosticCode "TcRnIllegalImplicitParam" = 75863
GhcDiagnosticCode "TcRnIllegalConstraintSynonymOfKind" = 75844 GhcDiagnosticCode "TcRnIllegalConstraintSynonymOfKind" = 75844
GhcDiagnosticCode "TcRnIllegalClassInst" = 53946
GhcDiagnosticCode "TcRnOversaturatedVisibleKindArg" = 45474 GhcDiagnosticCode "TcRnOversaturatedVisibleKindArg" = 45474
GhcDiagnosticCode "TcRnBadAssociatedType" = 38351
GhcDiagnosticCode "TcRnForAllRankErr" = 91510 GhcDiagnosticCode "TcRnForAllRankErr" = 91510
GhcDiagnosticCode "TcRnMonomorphicBindings" = 55524 GhcDiagnosticCode "TcRnMonomorphicBindings" = 55524
GhcDiagnosticCode "TcRnOrphanInstance" = 90177 GhcDiagnosticCode "TcRnOrphanInstance" = 90177
...@@ -422,7 +419,6 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -422,7 +419,6 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnPartialTypeSignatures" = 60661 GhcDiagnosticCode "TcRnPartialTypeSignatures" = 60661
GhcDiagnosticCode "TcRnLazyGADTPattern" = 87005 GhcDiagnosticCode "TcRnLazyGADTPattern" = 87005
GhcDiagnosticCode "TcRnArrowProcGADTPattern" = 64525 GhcDiagnosticCode "TcRnArrowProcGADTPattern" = 64525
GhcDiagnosticCode "TcRnSpecialClassInst" = 97044
GhcDiagnosticCode "TcRnForallIdentifier" = 64088 GhcDiagnosticCode "TcRnForallIdentifier" = 64088
GhcDiagnosticCode "TcRnTypeEqualityOutOfScope" = 12003 GhcDiagnosticCode "TcRnTypeEqualityOutOfScope" = 12003
GhcDiagnosticCode "TcRnTypeEqualityRequiresOperators" = 58520 GhcDiagnosticCode "TcRnTypeEqualityRequiresOperators" = 58520
...@@ -489,15 +485,11 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -489,15 +485,11 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnDefaultMethodForPragmaLacksBinding" = 28587 GhcDiagnosticCode "TcRnDefaultMethodForPragmaLacksBinding" = 28587
GhcDiagnosticCode "TcRnIgnoreSpecialisePragmaOnDefMethod" = 72520 GhcDiagnosticCode "TcRnIgnoreSpecialisePragmaOnDefMethod" = 72520
GhcDiagnosticCode "TcRnBadMethodErr" = 46284 GhcDiagnosticCode "TcRnBadMethodErr" = 46284
GhcDiagnosticCode "TcRnNoExplicitAssocTypeOrDefaultDeclaration" = 08585
GhcDiagnosticCode "TcRnIllegalTypeData" = 15013 GhcDiagnosticCode "TcRnIllegalTypeData" = 15013
GhcDiagnosticCode "TcRnTypeDataForbids" = 67297 GhcDiagnosticCode "TcRnTypeDataForbids" = 67297
GhcDiagnosticCode "TcRnInterfaceLookupError" = 52243 GhcDiagnosticCode "TcRnInterfaceLookupError" = 52243
GhcDiagnosticCode "TcRnUnsatisfiedMinimalDef" = 06201 GhcDiagnosticCode "TcRnUnsatisfiedMinimalDef" = 06201
GhcDiagnosticCode "TcRnMisplacedInstSig" = 06202 GhcDiagnosticCode "TcRnMisplacedInstSig" = 06202
GhcDiagnosticCode "TcRnIllegalFamilyInstance" = 06204
GhcDiagnosticCode "TcRnMissingClassAssoc" = 06205
GhcDiagnosticCode "TcRnNotOpenFamily" = 06207
GhcDiagnosticCode "TcRnCapturedTermName" = 54201 GhcDiagnosticCode "TcRnCapturedTermName" = 54201
GhcDiagnosticCode "TcRnBindingOfExistingName" = 58805 GhcDiagnosticCode "TcRnBindingOfExistingName" = 58805
GhcDiagnosticCode "TcRnMultipleFixityDecls" = 50419 GhcDiagnosticCode "TcRnMultipleFixityDecls" = 50419
...@@ -511,12 +503,10 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -511,12 +503,10 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnUnexpectedDefaultSig" = 40700 GhcDiagnosticCode "TcRnUnexpectedDefaultSig" = 40700
GhcDiagnosticCode "TcRnDuplicateMinimalSig" = 85346 GhcDiagnosticCode "TcRnDuplicateMinimalSig" = 85346
GhcDiagnosticCode "TcRnLoopySuperclassSolve" = 36038 GhcDiagnosticCode "TcRnLoopySuperclassSolve" = 36038
GhcDiagnosticCode "TcRnIllegalInstanceHeadDecl" = 12222
GhcDiagnosticCode "TcRnUnexpectedStandaloneDerivingDecl" = 95159 GhcDiagnosticCode "TcRnUnexpectedStandaloneDerivingDecl" = 95159
GhcDiagnosticCode "TcRnUnusedVariableInRuleDecl" = 65669 GhcDiagnosticCode "TcRnUnusedVariableInRuleDecl" = 65669
GhcDiagnosticCode "TcRnUnexpectedStandaloneKindSig" = 45906 GhcDiagnosticCode "TcRnUnexpectedStandaloneKindSig" = 45906
GhcDiagnosticCode "TcRnIllegalRuleLhs" = 63294 GhcDiagnosticCode "TcRnIllegalRuleLhs" = 63294
GhcDiagnosticCode "TcRnBadAssocRhs" = 53634
GhcDiagnosticCode "TcRnDuplicateRoleAnnot" = 97170 GhcDiagnosticCode "TcRnDuplicateRoleAnnot" = 97170
GhcDiagnosticCode "TcRnDuplicateKindSig" = 43371 GhcDiagnosticCode "TcRnDuplicateKindSig" = 43371
GhcDiagnosticCode "TcRnIllegalDerivStrategy" = 87139 GhcDiagnosticCode "TcRnIllegalDerivStrategy" = 87139
...@@ -535,7 +525,6 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -535,7 +525,6 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnPatSynEscapedCoercion" = 88986 GhcDiagnosticCode "TcRnPatSynEscapedCoercion" = 88986
GhcDiagnosticCode "TcRnPatSynExistentialInResult" = 33973 GhcDiagnosticCode "TcRnPatSynExistentialInResult" = 33973
GhcDiagnosticCode "TcRnPatSynArityMismatch" = 18365 GhcDiagnosticCode "TcRnPatSynArityMismatch" = 18365
GhcDiagnosticCode "TcRnMultiAssocTyFamDefaults" = 59128
GhcDiagnosticCode "TcRnTyFamDepsDisabled" = 43991 GhcDiagnosticCode "TcRnTyFamDepsDisabled" = 43991
GhcDiagnosticCode "TcRnAbstractClosedTyFamDecl" = 60012 GhcDiagnosticCode "TcRnAbstractClosedTyFamDecl" = 60012
GhcDiagnosticCode "TcRnPartialFieldSelector" = 82712 GhcDiagnosticCode "TcRnPartialFieldSelector" = 82712
...@@ -544,7 +533,6 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -544,7 +533,6 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnTyFamResultDisabled" = 44012 GhcDiagnosticCode "TcRnTyFamResultDisabled" = 44012
GhcDiagnosticCode "TcRnCommonFieldResultTypeMismatch" = 31004 GhcDiagnosticCode "TcRnCommonFieldResultTypeMismatch" = 31004
GhcDiagnosticCode "TcRnCommonFieldTypeMismatch" = 91827 GhcDiagnosticCode "TcRnCommonFieldTypeMismatch" = 91827
GhcDiagnosticCode "TcRnAssocNoClassTyVar" = 55912
GhcDiagnosticCode "TcRnDataConParentTypeMismatch" = 45219 GhcDiagnosticCode "TcRnDataConParentTypeMismatch" = 45219
GhcDiagnosticCode "TcRnGADTsDisabled" = 23894 GhcDiagnosticCode "TcRnGADTsDisabled" = 23894
GhcDiagnosticCode "TcRnExistentialQuantificationDisabled" = 25709 GhcDiagnosticCode "TcRnExistentialQuantificationDisabled" = 25709
...@@ -552,14 +540,11 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -552,14 +540,11 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnMultipleConForNewtype" = 16409 GhcDiagnosticCode "TcRnMultipleConForNewtype" = 16409
GhcDiagnosticCode "TcRnKindSignaturesDisabled" = 49378 GhcDiagnosticCode "TcRnKindSignaturesDisabled" = 49378
GhcDiagnosticCode "TcRnEmptyDataDeclsDisabled" = 32478 GhcDiagnosticCode "TcRnEmptyDataDeclsDisabled" = 32478
GhcDiagnosticCode "TcRnFamilyCategoryMismatch" = 52347
GhcDiagnosticCode "TcRnFamilyArityMismatch" = 12985
GhcDiagnosticCode "TcRnRoleMismatch" = 29178 GhcDiagnosticCode "TcRnRoleMismatch" = 29178
GhcDiagnosticCode "TcRnRoleCountMismatch" = 54298 GhcDiagnosticCode "TcRnRoleCountMismatch" = 54298
GhcDiagnosticCode "TcRnIllegalRoleAnnotation" = 77192 GhcDiagnosticCode "TcRnIllegalRoleAnnotation" = 77192
GhcDiagnosticCode "TcRnRoleAnnotationsDisabled" = 17779 GhcDiagnosticCode "TcRnRoleAnnotationsDisabled" = 17779
GhcDiagnosticCode "TcRnIncoherentRoles" = 18273 GhcDiagnosticCode "TcRnIncoherentRoles" = 18273
GhcDiagnosticCode "TcRnTyFamNameMismatch" = 88221
GhcDiagnosticCode "TcRnTypeSynonymCycle" = 97522 GhcDiagnosticCode "TcRnTypeSynonymCycle" = 97522
GhcDiagnosticCode "TcRnSelfImport" = 43281 GhcDiagnosticCode "TcRnSelfImport" = 43281
GhcDiagnosticCode "TcRnNoExplicitImportList" = 16029 GhcDiagnosticCode "TcRnNoExplicitImportList" = 16029
...@@ -591,6 +576,7 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -591,6 +576,7 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "TcRnSimplifiableConstraint" = 62412 GhcDiagnosticCode "TcRnSimplifiableConstraint" = 62412
GhcDiagnosticCode "TcRnIllegalQuasiQuotes" = 77343 GhcDiagnosticCode "TcRnIllegalQuasiQuotes" = 77343
GhcDiagnosticCode "TcRnImplicitRhsQuantification" = 16382 GhcDiagnosticCode "TcRnImplicitRhsQuantification" = 16382
GhcDiagnosticCode "TcRnBadTyConTelescope" = 87279
GhcDiagnosticCode "TcRnPatersonCondFailure" = 22979 GhcDiagnosticCode "TcRnPatersonCondFailure" = 22979
-- TcRnTypeApplicationsDisabled -- TcRnTypeApplicationsDisabled
...@@ -691,18 +677,50 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -691,18 +677,50 @@ type family GhcDiagnosticCode c = n | n -> c where
GhcDiagnosticCode "UnusedImportNone" = 66111 GhcDiagnosticCode "UnusedImportNone" = 66111
GhcDiagnosticCode "UnusedImportSome" = 38856 GhcDiagnosticCode "UnusedImportSome" = 38856
-- TcRnIllegalInstanceDecl -- TcRnIllegalInstance
GhcDiagnosticCode "IllegalInstanceHeadTypeSynonym" = 93557 GhcDiagnosticCode "IllegalFamilyApplicationInInstance" = 73138
GhcDiagnosticCode "IllegalInstanceHeadNonTyVarArgs" = 48406
GhcDiagnosticCode "IllegalMultiParamInstance" = 91901 -- TcRnIllegalClassInstance/IllegalClassInstanceReason
GhcDiagnosticCode "IllegalSpecialClassInstance" = 97044
GhcDiagnosticCode "IllegalInstanceFailsCoverageCondition" = 21572 GhcDiagnosticCode "IllegalInstanceFailsCoverageCondition" = 21572
-- TcRnIllegalHasFieldInstance -- IllegalInstanceHead
GhcDiagnosticCode "InstHeadAbstractClass" = 51758
GhcDiagnosticCode "InstHeadNonClass" = 53946
GhcDiagnosticCode "InstHeadTySynArgs" = 93557
GhcDiagnosticCode "InstHeadNonTyVarArgs" = 48406
GhcDiagnosticCode "InstHeadMultiParam" = 91901
-- IllegalHasFieldInstance
GhcDiagnosticCode "IllegalHasFieldInstanceNotATyCon" = 88994 GhcDiagnosticCode "IllegalHasFieldInstanceNotATyCon" = 88994
GhcDiagnosticCode "IllegalHasFieldInstanceFamilyTyCon" = 70743 GhcDiagnosticCode "IllegalHasFieldInstanceFamilyTyCon" = 70743
GhcDiagnosticCode "IllegalHasFieldInstanceTyConHasFields" = 43406 GhcDiagnosticCode "IllegalHasFieldInstanceTyConHasFields" = 43406
GhcDiagnosticCode "IllegalHasFieldInstanceTyConHasField" = 30836 GhcDiagnosticCode "IllegalHasFieldInstanceTyConHasField" = 30836
-- TcRnIllegalFamilyInstance/IllegalFamilyInstanceReason
GhcDiagnosticCode "NotAFamilyTyCon" = 06204
GhcDiagnosticCode "NotAnOpenFamilyTyCon" = 06207
GhcDiagnosticCode "FamilyCategoryMismatch" = 52347
GhcDiagnosticCode "FamilyArityMismatch" = 12985
GhcDiagnosticCode "TyFamNameMismatch" = 88221
GhcDiagnosticCode "FamInstRHSOutOfScopeTyVars" = 53634
GhcDiagnosticCode "FamInstLHSUnusedBoundTyVars" = 30337
-- InvalidAssocInstance
GhcDiagnosticCode "AssocInstanceMissing" = 08585
GhcDiagnosticCode "AssocInstanceNotInAClass" = 06205
GhcDiagnosticCode "AssocNotInThisClass" = 38351
GhcDiagnosticCode "AssocNoClassTyVar" = 55912
GhcDiagnosticCode "AssocTyVarsDontMatch" = 95424
-- InvalidAssocDefault
GhcDiagnosticCode "AssocDefaultNotAssoc" = 78822
GhcDiagnosticCode "AssocMultipleDefaults" = 59128
-- AssocDefaultBadArgs
GhcDiagnosticCode "AssocDefaultNonTyVarArg" = 41522
GhcDiagnosticCode "AssocDefaultDuplicateTyVars" = 48178
-- Diagnostic codes for the foreign function interface -- Diagnostic codes for the foreign function interface
GhcDiagnosticCode "NotADataType" = 31136 GhcDiagnosticCode "NotADataType" = 31136
GhcDiagnosticCode "NewtypeDataConNotInScope" = 72317 GhcDiagnosticCode "NewtypeDataConNotInScope" = 72317
...@@ -840,6 +858,10 @@ type family GhcDiagnosticCode c = n | n -> c where ...@@ -840,6 +858,10 @@ type family GhcDiagnosticCode c = n | n -> c where
-- and this includes outdated diagnostic codes for errors that GHC -- and this includes outdated diagnostic codes for errors that GHC
-- no longer reports. These are collected below. -- no longer reports. These are collected below.
GhcDiagnosticCode "TcRnIllegalInstanceHeadDecl" = 12222
GhcDiagnosticCode "TcRnNoClassInstHead" = 56538
-- The above two are subsumed by InstHeadNonClass [GHC-53946]
GhcDiagnosticCode "TcRnNameByTemplateHaskellQuote" = 40027 GhcDiagnosticCode "TcRnNameByTemplateHaskellQuote" = 40027
GhcDiagnosticCode "TcRnIllegalBindingOfBuiltIn" = 69639 GhcDiagnosticCode "TcRnIllegalBindingOfBuiltIn" = 69639
GhcDiagnosticCode "TcRnMixedSelectors" = 40887 GhcDiagnosticCode "TcRnMixedSelectors" = 40887
...@@ -927,12 +949,24 @@ type family ConRecursInto con where ...@@ -927,12 +949,24 @@ type family ConRecursInto con where
ConRecursInto "TcRnImportLookup" = 'Just ImportLookupReason ConRecursInto "TcRnImportLookup" = 'Just ImportLookupReason
ConRecursInto "TcRnUnusedImport" = 'Just UnusedImportReason ConRecursInto "TcRnUnusedImport" = 'Just UnusedImportReason
ConRecursInto "TcRnNonCanonicalDefinition" = 'Just NonCanonicalDefinition ConRecursInto "TcRnNonCanonicalDefinition" = 'Just NonCanonicalDefinition
ConRecursInto "TcRnIllegalInstanceDecl" = 'Just IllegalInstanceReason ConRecursInto "TcRnIllegalInstance" = 'Just IllegalInstanceReason
ConRecursInto "TcRnTypeApplicationsDisabled" = 'Just TypeApplication ConRecursInto "TcRnTypeApplicationsDisabled" = 'Just TypeApplication
-- Illegal instance reasons -- Illegal instance reasons
ConRecursInto "IllegalClassInstance" = 'Just IllegalClassInstanceReason
ConRecursInto "IllegalFamilyInstance" = 'Just IllegalFamilyInstanceReason
-- Illegal class instance reasons
ConRecursInto "IllegalInstanceHead" = 'Just IllegalInstanceHeadReason
ConRecursInto "IllegalHasFieldInstance" = 'Just IllegalHasFieldInstance
-- Illegal family instance reasons
ConRecursInto "IllegalHasFieldInstance" = 'Just IllegalHasFieldInstance ConRecursInto "InvalidAssoc" = 'Just InvalidAssoc
ConRecursInto "InvalidAssocInstance" = 'Just InvalidAssocInstance
ConRecursInto "InvalidAssocDefault" = 'Just InvalidAssocDefault
ConRecursInto "AssocDefaultBadArgs" = 'Just AssocDefaultBadArgs
-- --
-- TH errors -- TH errors
......
...@@ -250,7 +250,6 @@ data GhcHint ...@@ -250,7 +250,6 @@ data GhcHint
-} -}
| SuggestAddToHSigExportList !Name !(Maybe Module) | SuggestAddToHSigExportList !Name !(Maybe Module)
{-| Suggests increasing the limit for the number of iterations in the simplifier. {-| Suggests increasing the limit for the number of iterations in the simplifier.
-} -}
| SuggestIncreaseSimplifierIterations | SuggestIncreaseSimplifierIterations
{-| Suggests to explicitly import 'Type' from the 'Data.Kind' module, because {-| Suggests to explicitly import 'Type' from the 'Data.Kind' module, because
...@@ -455,6 +454,9 @@ data GhcHint ...@@ -455,6 +454,9 @@ data GhcHint
Name -- ^ ... to this method Name -- ^ ... to this method
String -- ^ Documentation URL String -- ^ Documentation URL
{-| Suggest to increase the solver maximum reduction depth -}
| SuggestIncreaseReductionDepth
{-| Suggest removing a method implementation when a superclass defines the {-| Suggest removing a method implementation when a superclass defines the
canonical version of that method. canonical version of that method.
-} -}
......
...@@ -238,6 +238,12 @@ instance Outputable GhcHint where ...@@ -238,6 +238,12 @@ instance Outputable GhcHint where
-> text "Enable Safe Haskell through either Safe, Trustworthy or Unsafe." -> text "Enable Safe Haskell through either Safe, Trustworthy or Unsafe."
SuggestRemoveRecordWildcard SuggestRemoveRecordWildcard
-> text "Omit the" <+> quotes (text "..") -> text "Omit the" <+> quotes (text "..")
SuggestIncreaseReductionDepth ->
vcat
[ text "Use -freduction-depth=0 to disable this check"
, text "(any upper bound you could choose might fail unpredictably with"
, text " minor updates to GHC, so disabling the check is recommended if"
, text " you're sure that type checking should terminate)" ]
SuggestMoveNonCanonicalDefinition lhs rhs refURL -> SuggestMoveNonCanonicalDefinition lhs rhs refURL ->
text "Move definition from" <+> text "Move definition from" <+>
quotes (pprPrefixUnqual rhs) <+> quotes (pprPrefixUnqual rhs) <+>
......
...@@ -50,7 +50,7 @@ import sphinx ...@@ -50,7 +50,7 @@ import sphinx
from sphinx import addnodes from sphinx import addnodes
from sphinx.domains.std import GenericObject from sphinx.domains.std import GenericObject
from sphinx.errors import SphinxError from sphinx.errors import SphinxError
from distutils.version import LooseVersion from packaging.version import parse
from utils import build_table_from_list from utils import build_table_from_list
import os.path import os.path
...@@ -628,8 +628,8 @@ def purge_flags(app, env, docname): ...@@ -628,8 +628,8 @@ def purge_flags(app, env, docname):
def setup(app): def setup(app):
# The override argument to add_directive_to_domain is only supported by >= 1.8 # The override argument to add_directive_to_domain is only supported by >= 1.8
sphinx_version = LooseVersion(sphinx.__version__) sphinx_version = parse(sphinx.__version__)
override_arg = {'override': True} if sphinx_version >= LooseVersion('1.8') else {} override_arg = {'override': True} if sphinx_version >= parse('1.8') else {}
# Add ghc-flag directive, and override the class with our own # Add ghc-flag directive, and override the class with our own
app.add_object_type('ghc-flag', 'ghc-flag') app.add_object_type('ghc-flag', 'ghc-flag')
......
...@@ -327,6 +327,9 @@ rtsCabalFlags = mconcat ...@@ -327,6 +327,9 @@ rtsCabalFlags = mconcat
where where
flag = interpolateCabalFlag flag = interpolateCabalFlag
ghcPrimCabalFlags :: Interpolations
ghcPrimCabalFlags = interpolateCabalFlag "CabalNeedLibatomic" NeedLibatomic
packageVersions :: Interpolations packageVersions :: Interpolations
packageVersions = foldMap f [ base, ghcPrim, compiler, ghc, cabal, templateHaskell, ghcCompact, array ] packageVersions = foldMap f [ base, ghcPrim, compiler, ghc, cabal, templateHaskell, ghcCompact, array ]
where where
...@@ -346,6 +349,7 @@ templateRules :: Rules () ...@@ -346,6 +349,7 @@ templateRules :: Rules ()
templateRules = do templateRules = do
templateRule "compiler/ghc.cabal" $ projectVersion templateRule "compiler/ghc.cabal" $ projectVersion
templateRule "rts/rts.cabal" $ rtsCabalFlags templateRule "rts/rts.cabal" $ rtsCabalFlags
templateRule "libraries/ghc-prim/ghc-prim.cabal" $ ghcPrimCabalFlags
templateRule "driver/ghci/ghci-wrapper.cabal" $ projectVersion templateRule "driver/ghci/ghci-wrapper.cabal" $ projectVersion
templateRule "ghc/ghc-bin.cabal" $ projectVersion templateRule "ghc/ghc-bin.cabal" $ projectVersion
templateRule "utils/iserv/iserv.cabal" $ projectVersion templateRule "utils/iserv/iserv.cabal" $ projectVersion
......
...@@ -50,6 +50,10 @@ haddockBuilderArgs = mconcat ...@@ -50,6 +50,10 @@ haddockBuilderArgs = mconcat
baseUrlTemplate <- expr (docsBaseUrl <$> userSetting defaultDocArgs) baseUrlTemplate <- expr (docsBaseUrl <$> userSetting defaultDocArgs)
let baseUrl p = substituteTemplate baseUrlTemplate p let baseUrl p = substituteTemplate baseUrlTemplate p
ghcOpts <- haddockGhcArgs ghcOpts <- haddockGhcArgs
-- These are the options which are necessary to perform the build. Additional
-- options such as `--hyperlinked-source`, `--hoogle`, `--quickjump` are
-- added by the `extraArgs` field in the flavour. The defaults are provided
-- by `defaultHaddockExtraArgs`.
mconcat mconcat
[ arg "--verbosity=0" [ arg "--verbosity=0"
, arg $ "-B" ++ root -/- stageString Stage1 -/- "lib" , arg $ "-B" ++ root -/- stageString Stage1 -/- "lib"
...@@ -57,9 +61,6 @@ haddockBuilderArgs = mconcat ...@@ -57,9 +61,6 @@ haddockBuilderArgs = mconcat
, arg $ "--odir=" ++ takeDirectory output , arg $ "--odir=" ++ takeDirectory output
, arg $ "--dump-interface=" ++ output , arg $ "--dump-interface=" ++ output
, arg "--html" , arg "--html"
, arg "--hyperlinked-source"
, arg "--hoogle"
, arg "--quickjump"
, arg $ "--title=" ++ pkgName pkg ++ "-" ++ version , arg $ "--title=" ++ pkgName pkg ++ "-" ++ version
++ ": " ++ synopsis ++ ": " ++ synopsis
, arg $ "--prologue=" ++ takeDirectory output -/- "haddock-prologue.txt" , arg $ "--prologue=" ++ takeDirectory output -/- "haddock-prologue.txt"
......
...@@ -7,7 +7,7 @@ module Settings.Default ( ...@@ -7,7 +7,7 @@ module Settings.Default (
-- * Default command line arguments for various builders -- * Default command line arguments for various builders
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs, SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
defaultExtraArgs, defaultExtraArgs, defaultHaddockExtraArgs,
-- * Default build flavour and BigNum backend -- * Default build flavour and BigNum backend
defaultFlavour, defaultBignumBackend defaultFlavour, defaultBignumBackend
...@@ -219,7 +219,13 @@ sourceArgs SourceArgs {..} = builder Ghc ? mconcat ...@@ -219,7 +219,13 @@ sourceArgs SourceArgs {..} = builder Ghc ? mconcat
-- | All default command line arguments. -- | All default command line arguments.
defaultExtraArgs :: Args defaultExtraArgs :: Args
defaultExtraArgs = sourceArgs defaultSourceArgs defaultExtraArgs =
mconcat [ sourceArgs defaultSourceArgs, defaultHaddockExtraArgs ]
defaultHaddockExtraArgs :: Args
defaultHaddockExtraArgs = builder (Haddock BuildPackage) ?
mconcat [ arg "--hyperlinked-source", arg "--hoogle", arg "--quickjump" ]
-- | Default source arguments, e.g. optimisation settings. -- | Default source arguments, e.g. optimisation settings.
defaultSourceArgs :: SourceArgs defaultSourceArgs :: SourceArgs
......
module Settings.Default ( module Settings.Default (
SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs, SourceArgs (..), sourceArgs, defaultBuilderArgs, defaultPackageArgs,
defaultExtraArgs, defaultLibraryWays, defaultRtsWays, defaultExtraArgs, defaultHaddockExtraArgs, defaultLibraryWays, defaultRtsWays,
defaultFlavour, defaultBignumBackend defaultFlavour, defaultBignumBackend
) where ) where
...@@ -15,7 +15,7 @@ data SourceArgs = SourceArgs ...@@ -15,7 +15,7 @@ data SourceArgs = SourceArgs
sourceArgs :: SourceArgs -> Args sourceArgs :: SourceArgs -> Args
defaultBuilderArgs, defaultPackageArgs, defaultExtraArgs :: Args defaultBuilderArgs, defaultPackageArgs, defaultExtraArgs, defaultHaddockExtraArgs :: Args
defaultLibraryWays, defaultRtsWays :: Ways defaultLibraryWays, defaultRtsWays :: Ways
defaultFlavour :: Flavour defaultFlavour :: Flavour
defaultBignumBackend :: String defaultBignumBackend :: String
...@@ -10,7 +10,7 @@ import {-# SOURCE #-} Settings.Default ...@@ -10,7 +10,7 @@ import {-# SOURCE #-} Settings.Default
benchmarkFlavour :: Flavour benchmarkFlavour :: Flavour
benchmarkFlavour = defaultFlavour benchmarkFlavour = defaultFlavour
{ name = "bench" { name = "bench"
, extraArgs = benchmarkArgs , extraArgs = benchmarkArgs <> defaultHaddockExtraArgs
, libraryWays = pure $ Set.fromList [vanilla] , libraryWays = pure $ Set.fromList [vanilla]
, rtsWays = Set.fromList <$> mconcat [pure [vanilla], targetSupportsThreadedRts ? pure [threaded]] } , rtsWays = Set.fromList <$> mconcat [pure [vanilla], targetSupportsThreadedRts ? pure [threaded]] }
......
...@@ -12,7 +12,7 @@ import {-# SOURCE #-} Settings.Default ...@@ -12,7 +12,7 @@ import {-# SOURCE #-} Settings.Default
developmentFlavour :: Stage -> Flavour developmentFlavour :: Stage -> Flavour
developmentFlavour ghcStage = defaultFlavour developmentFlavour ghcStage = defaultFlavour
{ name = "devel" ++ stageString ghcStage { name = "devel" ++ stageString ghcStage
, extraArgs = developmentArgs ghcStage , extraArgs = developmentArgs ghcStage <> defaultHaddockExtraArgs
, libraryWays = pure $ Set.fromList [vanilla] , libraryWays = pure $ Set.fromList [vanilla]
, rtsWays = Set.fromList <$> mconcat [pure [vanilla, debug], targetSupportsThreadedRts ? pure [threaded, threadedDebug]] , rtsWays = Set.fromList <$> mconcat [pure [vanilla, debug], targetSupportsThreadedRts ? pure [threaded, threadedDebug]]
, dynamicGhcPrograms = return False , dynamicGhcPrograms = return False
......