diff --git a/compiler/basicTypes/MkId.hs b/compiler/basicTypes/MkId.hs index f690732909c96da02be38930db878f5e0a525b45..f796d76853352ca97add0cb73b139b58688374ff 100644 --- a/compiler/basicTypes/MkId.hs +++ b/compiler/basicTypes/MkId.hs @@ -1179,7 +1179,14 @@ oneShotId = pcMiscPrelId oneShotName ty info runRWId :: Id -- See Note [runRW magic] in this module runRWId = pcMiscPrelId runRWName ty info where - info = noCafIdInfo `setInlinePragInfo` neverInlinePragma + info = noCafIdInfo `setInlinePragInfo` neverInlinePragma + `setStrictnessInfo` strict_sig + `setArityInfo` 1 + strict_sig = mkClosedStrictSig [strictApply1Dmd] topRes + -- Important to express its strictness, + -- since it is not inlined until CorePrep + -- Also see Note [runRW arg] in CorePrep + -- State# RealWorld stateRW = mkTyConApp statePrimTyCon [realWorldTy] -- (# State# RealWorld, o #) diff --git a/compiler/coreSyn/CorePrep.hs b/compiler/coreSyn/CorePrep.hs index adaad613c82eec79e0d0b025ed99315c8d4c38f9..df18f8b5f124bf2eea4b6e1028d92ef58dcfe719 100644 --- a/compiler/coreSyn/CorePrep.hs +++ b/compiler/coreSyn/CorePrep.hs @@ -518,6 +518,18 @@ cpeRhsE env (Var f `App` _levity `App` _type `App` arg) = case arg of -- beta reducing if possible Lam s body -> cpeRhsE (extendCorePrepEnv env s realWorldPrimId) body _ -> cpeRhsE env (arg `App` Var realWorldPrimId) + -- See Note [runRW arg] + +{- Note [runRW arg] +~~~~~~~~~~~~~~~~~~~ +If we got, say + runRW# (case bot of {}) +which happened in Trac #11291, we do /not/ want to turn it into + (case bot of {}) realWorldPrimId# +because that gives a panic in CoreToStg.myCollectArgs, which expects +only variables in function position. But if we are sure to make +runRW# strict (which we do in MkId), this can't happen +-} cpeRhsE env expr@(App {}) = cpeApp env expr diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 3fa1f8cfaa9e561a33fdba4ac8ee7166957cd0ab..0c1d0c1d98e346c4bdb1cc50f3a88d39af60a41b 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -383,7 +383,8 @@ test('T5792',normal,run_command, test('PolytypeDecomp', normal, compile, ['']) test('T6011', normal, compile, ['']) test('T6055', normal, compile, ['']) -test('DfltProb1', normal, compile, ['']) +test('DfltProb1', normal, compile, ['-O']) +# Add -O for DfltProb1 to expose Trac #11291 test('DfltProb2', normal, compile, ['']) test('T6134', normal, compile, ['']) test('T6018', extra_clean(['T6018.hi' , 'T6018.o'