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
Commits on Source (6)
Showing
with 258 additions and 95 deletions
......@@ -2535,13 +2535,14 @@ kcCheckDeclHeader_sig sig_kind name flav
-- ^^^^^^^^^
-- We do it here because at this point the environment has been
-- extended with both 'implicit_tcv_prs' and 'explicit_tv_prs'.
; ctx_k <- kc_res_ki
; res_kind :: ContextKind <- kc_res_ki
-- Work out extra_arity, the number of extra invisible binders from
-- the kind signature that should be part of the TyCon's arity.
-- See Note [Arity inference in kcCheckDeclHeader_sig]
; let n_invis_tcbs = countWhile isInvisibleTyConBinder excess_sig_tcbs
invis_arity = case ctx_k of
invis_arity = case res_kind of
AnyKind -> n_invis_tcbs -- No kind signature, so make all the invisible binders
-- the signature into part of the arity of the TyCon
OpenKind -> n_invis_tcbs -- Result kind is (TYPE rr), so again make all the
......@@ -2555,12 +2556,9 @@ kcCheckDeclHeader_sig sig_kind name flav
, ppr invis_arity, ppr invis_tcbs
, ppr n_invis_tcbs ]
-- Unify res_ki (from the type declaration) with the residual kind from
-- the kind signature. Don't forget to apply the skolemising 'subst' first.
; case ctx_k of
AnyKind -> return () -- No signature
_ -> do { res_ki <- newExpectedKind ctx_k
; discardResult (unifyKind Nothing sig_res_kind' res_ki) }
-- Unify res_ki (from the type declaration) with
-- sig_res_kind', the residual kind from the kind signature.
; checkExpectedResKind sig_res_kind' res_kind
-- Add more binders for data/newtype, so the result kind has no arrows
-- See Note [Datatype return kinds]
......@@ -2583,7 +2581,7 @@ kcCheckDeclHeader_sig sig_kind name flav
; implicit_tvs <- zonkTcTyVarsToTcTyVars implicit_tvs
; let implicit_prs = implicit_nms `zip` implicit_tvs
; checkForDuplicateScopedTyVars implicit_prs
; checkForDisconnectedScopedTyVars all_tcbs implicit_prs
; checkForDisconnectedScopedTyVars flav all_tcbs implicit_prs
-- Swizzle the Names so that the TyCon uses the user-declared implicit names
-- E.g type T :: k -> Type
......@@ -2620,6 +2618,27 @@ kcCheckDeclHeader_sig sig_kind name flav
]
; return tc }
-- | Check the result kind annotation on a type constructor against
-- the corresponding section of the standalone kind signature.
-- Drops invisible binders that interfere with unification.
checkExpectedResKind :: TcKind -- ^ the result kind from the separate kind signature
-> ContextKind -- ^ the result kind from the declaration header
-> TcM ()
checkExpectedResKind _ AnyKind
= return () -- No signature in the declaration header
checkExpectedResKind sig_kind res_ki
= do { actual_res_ki <- newExpectedKind res_ki
; let -- Drop invisible binders from sig_kind until they match up
-- with res_ki. By analogy with checkExpectedKind.
n_res_invis_bndrs = invisibleTyBndrCount actual_res_ki
n_sig_invis_bndrs = invisibleTyBndrCount sig_kind
n_to_inst = n_sig_invis_bndrs - n_res_invis_bndrs
(_, sig_kind') = splitInvisPiTysN n_to_inst sig_kind
; discardResult $ unifyKind Nothing sig_kind' actual_res_ki }
matchUpSigWithDecl
:: [TcTyConBinder] -- TcTyConBinders (with skolem TcTyVars) from the separate kind signature
-> TcKind -- The tail end of the kind signature
......@@ -2987,13 +3006,16 @@ expectedKindInCtxt _ = OpenKind
* *
********************************************************************* -}
checkForDisconnectedScopedTyVars :: [TcTyConBinder] -> [(Name,TcTyVar)] -> TcM ()
checkForDisconnectedScopedTyVars :: TyConFlavour -> [TcTyConBinder]
-> [(Name,TcTyVar)] -> TcM ()
-- See Note [Disconnected type variables]
-- `scoped_prs` is the mapping gotten by unifying
-- - the standalone kind signature for T, with
-- - the header of the type/class declaration for T
checkForDisconnectedScopedTyVars sig_tcbs scoped_prs
= mapM_ report_disconnected (filterOut ok scoped_prs)
checkForDisconnectedScopedTyVars flav sig_tcbs scoped_prs
= when (needsEtaExpansion flav) $
-- needsEtaExpansion: see wrinkle (DTV1) in Note [Disconnected type variables]
mapM_ report_disconnected (filterOut ok scoped_prs)
where
sig_tvs = mkVarSet (binderVars sig_tcbs)
ok (_, tc_tv) = tc_tv `elemVarSet` sig_tvs
......@@ -3070,6 +3092,25 @@ phantom synonym that just discards its argument. So our plan is this:
See #24083 for dicussion of alternatives, none satisfactory. Also the fix is
easy: just add an explicit `@kk` parameter to the declaration, to bind `kk`
explicitly, rather than binding it implicitly via unification.
(DTV1) We only want to make this check when there /are/ scoped type variables; and
that is determined by needsEtaExpansion. Examples:
type C :: x -> y -> Constraint
class C a :: b -> Constraint where { ... }
-- The a,b scope over the "..."
type D :: forall k. k -> Type
data family D :: kk -> Type
-- Nothing for `kk` to scope over!
In the latter data-family case, the match-up stuff in kcCheckDeclHeader_sig will
return [] for `extra_tcbs`, and in fact `all_tcbs` will be empty. So if we do
the check-for-disconnected-tyvars check we'll complain that `kk` is not bound
to one of `all_tcbs` (see #24083, comments about the `singletons` package).
The scoped-tyvar stuff is needed precisely for data/class/newtype declarations,
where needsEtaExpansion is True.
-}
{- *********************************************************************
......
......@@ -30,7 +30,9 @@ ghcWarningsArgs = do
, package binary ? pure [ "-Wno-deprecations" ]
, package bytestring ? pure [ "-Wno-inline-rule-shadowing" ]
, package compiler ? pure [ "-Wcpp-undef" ]
, package directory ? pure [ "-Wno-unused-imports" ]
, package directory ? pure [ "-Wno-unused-imports"
, "-Wno-deprecations" -- https://gitlab.haskell.org/ghc/ghc/-/issues/24240
]
, package ghc ? pure [ "-Wcpp-undef"
, "-Wincomplete-uni-patterns"
, "-Wincomplete-record-updates"
......@@ -53,5 +55,7 @@ ghcWarningsArgs = do
, "-Wno-redundant-constraints"
, "-Wno-orphans" ]
, package unix ? pure [ "-Wno-deprecations" ]
, package win32 ? pure [ "-Wno-trustworthy-safe" ]
, package win32 ? pure [ "-Wno-trustworthy-safe"
, "-Wno-deprecations" -- https://gitlab.haskell.org/ghc/ghc/-/issues/24240
]
, package xhtml ? pure [ "-Wno-unused-imports" ] ] ]
Subproject commit f487b8de85f2b271a3831c14ab6439b9bc9b8343
Subproject commit 0daca5dfa33d6c522e9fb8e94a2b66a5ed658c20
Subproject commit 367f6bffc158ef1a9055fb876e23447636853aa4
Subproject commit cdb5171f7774569b1a8028a78392cfa79f732b5c
Subproject commit 720debbf5b89366007bac473e8d7fd18e4114f1a
Subproject commit 0b3dbc9901fdf2d752c4ee7a7cee7b1ed20e76bd
......@@ -18,12 +18,12 @@ import System.Exit
-- text
import qualified Data.Text as T
import qualified Data.Text.IO as T
( putStrLn )
( putStrLn, putStr )
-- linters-common
import Linters.Common
( GitType(..)
, gitBranchesContain, gitCatCommit, gitDiffTree, gitNormCid
, gitBranchesContain, gitIsTagged, gitCatCommit, gitDiffTree, gitNormCid
)
--------------------------------------------------------------------------------
......@@ -51,16 +51,18 @@ main = do
exitWith (ExitFailure 1)
bad <- fmap or $ forM smDeltas $ \(smPath,smCid) -> do
T.putStrLn $ " - " <> smPath <> " => " <> smCid
T.putStr $ " - " <> smPath <> " => " <> smCid
let smAbsPath = dir ++ "/" ++ T.unpack smPath
remoteBranches <- gitBranchesContain smAbsPath smCid
isTagged <- gitIsTagged smAbsPath smCid
let (wip, nonWip) = partition ("wip/" `T.isPrefixOf`) originBranches
originBranches = mapMaybe isOriginTracking remoteBranches
isOriginTracking = T.stripPrefix "origin/"
let bad = null nonWip
when bad $ do
case (nonWip ++ isTagged) of
[] -> do
T.putStrLn " ... BAD"
T.putStrLn $ " *FAIL* commit not found in submodule repo"
T.putStrLn " or not reachable from persistent branches"
T.putStrLn ""
......@@ -70,8 +72,15 @@ main = do
commit <- gitNormCid smAbsPath ("origin/" <> branch)
T.putStrLn $ " - " <> branch <> " -> " <> commit
T.putStrLn ""
pure bad
return True
(b:bs) -> do
let more = case bs of
[] -> ")"
rest -> " and " <> T.pack (show (length rest)) <> " more)"
T.putStrLn $ "... OK (" <> b <> more
return False
if bad
then exitWith (ExitFailure 1)
else T.putStrLn " OK"
else T.putStrLn "OK"
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
......@@ -105,6 +106,10 @@ gitBranchesContain d ref = do
return $!! map (T.drop 2) tmp
gitIsTagged :: FilePath -> GitRef -> Sh [Text]
gitIsTagged d ref =
T.lines <$> runGit d "tag" ["--points-at", ref]
-- | returns @[(path, (url, key))]@
--
-- may throw exception
......
......@@ -374,12 +374,12 @@ StgClosure *captureContinuationAndAbort(Capability *cap, StgTSO *tso, StgPromptT
// 1. We walk the stack to find the prompt frame to capture up to (if any).
//
// 2. If we successfully find a matching prompt, we proceed with the actual
// by allocating space for the continuation, performing the necessary
// copying, and unwinding the stack.
// capture by allocating space for the continuation, performing the
// necessary copying, and unwinding the stack.
//
// These variables are modified in Phase 1 to keep track of how far we had to
// walk before finding the prompt frame. Afterwards, Phase 2 consults them to
// determine how to proceed with the actual capture.
// determine how to proceed.
StgWord total_words = 0;
bool in_first_chunk = true;
......
......@@ -393,16 +393,14 @@ stg_killMyself
* kind of return to the activation record underneath us on the stack.
*/
#define CATCH_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,exceptions_blocked,handler) \
#define CATCH_FRAME_FIELDS(w_,p_,info_ptr,p1,p2,handler) \
w_ info_ptr, \
PROF_HDR_FIELDS(w_,p1,p2) \
w_ exceptions_blocked, \
p_ handler
INFO_TABLE_RET(stg_catch_frame, CATCH_FRAME,
CATCH_FRAME_FIELDS(W_,P_,info_ptr, p1, p2,
exceptions_blocked,handler))
CATCH_FRAME_FIELDS(W_,P_,info_ptr, p1, p2,handler))
return (P_ ret)
{
return (ret);
......@@ -411,12 +409,7 @@ INFO_TABLE_RET(stg_catch_frame, CATCH_FRAME,
stg_catchzh ( P_ io, /* :: IO a */
P_ handler /* :: Exception -> IO a */ )
{
W_ exceptions_blocked;
STK_CHK_GEN();
exceptions_blocked =
TO_W_(StgTSO_flags(CurrentTSO)) & (TSO_BLOCKEX | TSO_INTERRUPTIBLE);
TICK_CATCHF_PUSHED();
/* Apply R1 to the realworld token */
......@@ -424,8 +417,7 @@ stg_catchzh ( P_ io, /* :: IO a */
TICK_SLOW_CALL_fast_v();
jump stg_ap_v_fast
(CATCH_FRAME_FIELDS(,,stg_catch_frame_info, CCCS, 0,
exceptions_blocked, handler))
(CATCH_FRAME_FIELDS(,,stg_catch_frame_info, CCCS, 0, handler))
(io);
}
......@@ -599,26 +591,28 @@ retry_pop_stack:
frame = Sp;
if (frame_type == CATCH_FRAME)
{
// Note: if this branch is updated, there is a good chance that
// corresponding logic in `raiseAsync` must be updated to match!
// See Note [Apply the handler directly in raiseAsync] in RaiseAsync.c.
Sp = Sp + SIZEOF_StgCatchFrame;
if ((StgCatchFrame_exceptions_blocked(frame) & TSO_BLOCKEX) == 0) {
W_ flags;
flags = TO_W_(StgTSO_flags(CurrentTSO));
if ((flags & TSO_BLOCKEX) == 0) {
Sp_adj(-1);
Sp(0) = stg_unmaskAsyncExceptionszh_ret_info;
}
/* Ensure that async exceptions are masked when running the handler.
*/
StgTSO_flags(CurrentTSO) = %lobits32(
TO_W_(StgTSO_flags(CurrentTSO)) | TSO_BLOCKEX | TSO_INTERRUPTIBLE);
/* The interruptible state is inherited from the context of the
*
* The interruptible state is inherited from the context of the
* catch frame, but note that TSO_INTERRUPTIBLE is only meaningful
* if TSO_BLOCKEX is set. (we got this wrong earlier, and #4988
* was a symptom of the bug).
*/
if ((StgCatchFrame_exceptions_blocked(frame) &
(TSO_BLOCKEX | TSO_INTERRUPTIBLE)) == TSO_BLOCKEX) {
StgTSO_flags(CurrentTSO) = %lobits32(
TO_W_(StgTSO_flags(CurrentTSO)) & ~TSO_INTERRUPTIBLE);
if ((flags & (TSO_BLOCKEX | TSO_INTERRUPTIBLE)) != TSO_BLOCKEX) {
StgTSO_flags(CurrentTSO) = %lobits32(flags | TSO_BLOCKEX | TSO_INTERRUPTIBLE);
}
}
else /* CATCH_STM_FRAME */
......
......@@ -950,44 +950,36 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception,
case CATCH_FRAME:
// If we find a CATCH_FRAME, and we've got an exception to raise,
// then build the THUNK raise(exception), and leave it on
// top of the CATCH_FRAME ready to enter.
//
// then set up the top of the stack to apply the handler;
// see Note [Apply the handler directly in raiseAsync].
{
StgCatchFrame *cf = (StgCatchFrame *)frame;
StgThunk *raise;
if (exception == NULL) break;
// we've got an exception to raise, so let's pass it to the
// handler in this frame.
//
raise = (StgThunk *)allocate(cap,sizeofW(StgThunk)+1);
TICK_ALLOC_SE_THK(WDS(1),0);
SET_HDR(raise,&stg_raise_info,cf->header.prof.ccs);
raise->payload[0] = exception;
StgClosure *handler = ((StgCatchFrame *)frame)->handler;
// throw away the stack from Sp up to the CATCH_FRAME.
//
sp = frame - 1;
/* Ensure that async exceptions are blocked now, so we don't get
* a surprise exception before we get around to executing the
* handler.
*/
tso->flags |= TSO_BLOCKEX;
if ((cf->exceptions_blocked & TSO_INTERRUPTIBLE) == 0) {
tso->flags &= ~TSO_INTERRUPTIBLE;
} else {
tso->flags |= TSO_INTERRUPTIBLE;
// Throw away the stack from Sp up to and including the CATCH_FRAME.
sp = frame + stack_frame_sizeW((StgClosure *)frame);
// Unmask async exceptions after running the handler, if necessary.
if ((tso->flags & TSO_BLOCKEX) == 0) {
sp--;
sp[0] = (W_)&stg_unmaskAsyncExceptionszh_ret_info;
}
/* Put the newly-built THUNK on top of the stack, ready to execute
* when the thread restarts.
*/
sp[0] = (W_)raise;
sp[-1] = (W_)&stg_enter_info;
stack->sp = sp-1;
// Ensure that async exceptions are masked while running the handler;
// see Note [Apply the handler directly in raiseAsync].
if ((tso->flags & (TSO_BLOCKEX | TSO_INTERRUPTIBLE)) != TSO_BLOCKEX) {
tso->flags |= TSO_BLOCKEX | TSO_INTERRUPTIBLE;
}
// Set up the top of the stack to apply the handler.
sp -= 4;
sp[0] = (W_)&stg_enter_info;
sp[1] = (W_)handler;
sp[2] = (W_)&stg_ap_pv_info;
sp[3] = (W_)exception;
stack->sp = sp;
RELAXED_STORE(&tso->what_next, ThreadRunGHC);
goto done;
}
......@@ -1079,6 +1071,15 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception,
};
default:
// see Note [Update async masking state on unwind] in Schedule.c
if (*frame == (W_)&stg_unmaskAsyncExceptionszh_ret_info) {
tso->flags &= ~(TSO_BLOCKEX | TSO_INTERRUPTIBLE);
} else if (*frame == (W_)&stg_maskAsyncExceptionszh_ret_info) {
tso->flags |= TSO_BLOCKEX | TSO_INTERRUPTIBLE;
} else if (*frame == (W_)&stg_maskUninterruptiblezh_ret_info) {
tso->flags |= TSO_BLOCKEX;
tso->flags &= ~TSO_INTERRUPTIBLE;
}
break;
}
......@@ -1097,3 +1098,26 @@ done:
return tso;
}
/* Note [Apply the handler directly in raiseAsync]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we encounter a `catch#` frame while unwinding the stack due to an
async exception, we need to set up the stack to resume execution by
invoking the exception handler. One natural way to do it would be to
simply place a `raise#` thunk on the top of the stack, ready to be
entered. This would effectively convert the asynchronous exception to
a synchronous one at a point where it’s known to be safe to do so.
However, there is a danger to this strategy: if async exceptions are
currently unmasked, it becomes possible for a second async exception
to be delivered before we enter the application of `raise#`, which
would result in the first exception being lost. The easiest way to
prevent this race from happening is to have `raiseAsync` set up the
stack to apply the handler directly, effectively emulating the
behavior of `raise#`, as this allows exceptions to be preemptively
masked before returning. This means `raiseAsync` must also push a
frame to unmask async exceptions after the handler returns if
necessary, just as `raise#` does.
This strategy results in some logical duplication, but it is correct,
and the duplicated logic is small enough to be acceptable. */
......@@ -3019,19 +3019,6 @@ raiseExceptionHelper (StgRegTable *reg, StgTSO *tso, StgClosure *exception)
// thunks which are currently under evaluation.
//
// OLD COMMENT (we don't have MIN_UPD_SIZE now):
// LDV profiling: stg_raise_info has THUNK as its closure
// type. Since a THUNK takes at least MIN_UPD_SIZE words in its
// payload, MIN_UPD_SIZE is more appropriate than 1. It seems that
// 1 does not cause any problem unless profiling is performed.
// However, when LDV profiling goes on, we need to linearly scan
// small object pool, where raise_closure is stored, so we should
// use MIN_UPD_SIZE.
//
// raise_closure = (StgClosure *)RET_STGCALL1(P_,allocate,
// sizeofW(StgClosure)+1);
//
//
// Walk up the stack, looking for the catch frame. On the way,
// we update any closures pointed to from update frames with the
......@@ -3094,12 +3081,52 @@ raiseExceptionHelper (StgRegTable *reg, StgTSO *tso, StgClosure *exception)
}
default:
// see Note [Update async masking state on unwind]
if (*p == (StgWord)&stg_unmaskAsyncExceptionszh_ret_info) {
tso->flags &= ~(TSO_BLOCKEX | TSO_INTERRUPTIBLE);
} else if (*p == (StgWord)&stg_maskAsyncExceptionszh_ret_info) {
tso->flags |= TSO_BLOCKEX | TSO_INTERRUPTIBLE;
} else if (*p == (StgWord)&stg_maskUninterruptiblezh_ret_info) {
tso->flags |= TSO_BLOCKEX;
tso->flags &= ~TSO_INTERRUPTIBLE;
}
p = next;
continue;
}
}
}
/* Note [Update async masking state on unwind]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we raise an exception or capture a continuation, we unwind the
stack by searching for an enclosing `catch#` or `prompt#` frame. If we
unwind past frames intended to restore the async exception masking
state, we must take care to reproduce their intended effect in order
to ensure that async exceptions are properly unmasked or remasked.
On paper, this seems as simple as updating `tso->flags` appropriately,
but in fact there is one additional wrinkle: when async exceptions are
*unmasked*, we must eagerly check for a pending async exception and
raise it if necessary. This is not terribly involved, but it’s not
trivial, either (see the definition of `stg_unmaskAsyncExceptionszh_ret`),
so we’d prefer to avoid duplicating that logic in several places.
Fortunately, when we’re unwinding the stack due to a raised exception,
this detail is actually unimportant: `catch#` implicitly masks async
exceptions while running the handler as we explicitly *don’t* want the
thread to be interrupted before it has a chance to handle the
exception. However, when capturing a continuation, we don’t have this
luxury, so we take two different strategies:
* When unwinding the stack due to a raised exception (synchonrous or
asynchronous), we just update `tso->flags` directly and take no
further action.
* When unwinding the stack due to a continuation capture, we update
the masking state *indirectly* by pushing an appropriate frame onto
the stack before we return. This strategy is described at length
in Note [Continuations and async exception masking] in Continuation.c. */
/* -----------------------------------------------------------------------------
findRetryFrameHelper
......
......@@ -275,7 +275,6 @@ typedef struct {
// Closure types: CATCH_FRAME
typedef struct {
StgHeader header;
StgWord exceptions_blocked;
StgClosure *handler;
} StgCatchFrame;
......
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ScopedTypeVariables, RankNTypes #-}
module T24083a where
type TyCon :: (k1 -> k2) -> unmatchable_fun
data family TyCon :: (k1 -> k2) -> unmatchable_fun
......@@ -243,3 +243,4 @@ test('T22379a', normal, compile, [''])
test('T22379b', normal, compile, [''])
test('T22743', normal, compile_fail, [''])
test('T24083', normal, compile_fail, [''])
test('T24083a', normal, compile, [''])
-- This test checks that restoring a continuation that captures a CATCH frame
-- properly adjusts the async exception masking state.
import Control.Exception
import Data.IORef
import ContIO
data E = E deriving (Show)
instance Exception E
printMaskingState :: IO ()
printMaskingState = print =<< getMaskingState
main :: IO ()
main = do
tag <- newPromptTag
ref <- newIORef Nothing
mask_ $ prompt tag $
catch (control0 tag $ \k ->
writeIORef ref (Just k))
(\E -> printMaskingState)
Just k <- readIORef ref
let execute_test = do
k (printMaskingState *> throwIO E)
printMaskingState
putStrLn "initially unmasked:"
execute_test
putStrLn "\ninitially interruptibly masked:"
mask_ execute_test
putStrLn "\ninitially uninterruptibly masked:"
uninterruptibleMask_ execute_test
initially unmasked:
Unmasked
MaskedInterruptible
Unmasked
initially interruptibly masked:
MaskedInterruptible
MaskedInterruptible
MaskedInterruptible
initially uninterruptibly masked:
MaskedUninterruptible
MaskedUninterruptible
MaskedUninterruptible
......@@ -7,3 +7,5 @@ test('cont_exn_masking', [extra_files(['ContIO.hs'])], multimod_compile_and_run,
test('cont_missing_prompt_err', [extra_files(['ContIO.hs']), exit_code(1)], multimod_compile_and_run, ['cont_missing_prompt_err', ''])
test('cont_nondet_handler', [extra_files(['ContIO.hs'])], multimod_compile_and_run, ['cont_nondet_handler', ''])
test('cont_stack_overflow', [extra_files(['ContIO.hs'])], multimod_compile_and_run, ['cont_stack_overflow', '-with-rtsopts "-ki1k -kc2k -kb256"'])
test('T23513', [extra_files(['ContIO.hs'])], multimod_compile_and_run, ['T23513', ''])
......@@ -482,7 +482,6 @@ wanteds os = concat
,closureField Both "StgUpdateFrame" "updatee"
,closureField C "StgCatchFrame" "handler"
,closureField C "StgCatchFrame" "exceptions_blocked"
,closureSize C "StgPAP"
,closureField C "StgPAP" "n_args"
......