Skip to content

CoreLint error in SpecConstr output for lateCC branch.

In !7797 (closed) I know hit a different core lint error in the output for SpecConstr.

In particular we try to specialise this function for True/False:

Input to SpecConstr:

              $wlistRest_s5qS [InlPrag=[2], Occ=LoopBreaker]
                :: Bool
                   -> forall b.
                      ([a_a23u] -> Text.ParserCombinators.ReadP.P b)
                      -> Text.ParserCombinators.ReadP.P b
              [LclId,
               Arity=1,
               Str=<L>,
               Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                       WorkFree=True, Expandable=True, Guidance=IF_ARGS [30] 280 60}]
              $wlistRest_s5qS
                = \ (started_s4ge :: Bool) (@b1_a3fH) ->
                    tick<$c>>=>
                    \ (k1_a3fI
                         :: [a_a23u] -> Text.ParserCombinators.ReadP.P b1_a3fH) ->
                      scc<$c>>=>
                      let {
                        lvl_s5n5 :: Text.ParserCombinators.ReadP.P b1_a3fH
                        [LclId,
                         Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
                                 WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}]
                        lvl_s5n5
                          = scc<$c>>=>
                            ((((pfail @[a_a23u])
                               `cast` <Co:3> :: ReadPrec [a_a23u] ~R# (Prec -> P.ReadP [a_a23u]))
                                n_s5mY)
                             `cast` <Co:3> :: P.ReadP [a_a23u]
                                              ~R# (forall b.
                                                   ([a_a23u] -> Text.ParserCombinators.ReadP.P b)
                                                   -> Text.ParserCombinators.ReadP.P b))
                              @b1_a3fH k1_a3fI } in
                      let {
                        lvl_s5na :: Text.ParserCombinators.ReadP.P b1_a3fH
                        [LclId,
                         Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
                                 WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 20 0}]
                        lvl_s5na
                          = scc<$c>>=> scc<$cpure> k1_a3fI (GHC.Types.[] @a_a23u) } in
                      let {
                        lvl_s5n8 :: Text.ParserCombinators.ReadP.P b1_a3fH
                        [LclId,
                         Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
                                 WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 20 0}]
                        lvl_s5n8
                          = scc<$c>>=>
                            (lvl_s5mZ
                             `cast` <Co:3> :: P.ReadP [a_a23u]
                                              ~R# (forall b.
                                                   ([a_a23u] -> Text.ParserCombinators.ReadP.P b)
                                                   -> Text.ParserCombinators.ReadP.P b))
                              @b1_a3fH k1_a3fI } in
                      scctick<$c>>=>
                      (ds1_s5n4
                       `cast` <Co:2> :: P.ReadP L.Lexeme
                                        ~R# (forall b.
                                             (L.Lexeme -> Text.ParserCombinators.ReadP.P b)
                                             -> Text.ParserCombinators.ReadP.P b))
                        @b1_a3fH
                        (\ (a1_a3fJ [Dmd=SL] :: L.Lexeme) ->
                           case a1_a3fJ of {
                             __DEFAULT -> Text.ParserCombinators.ReadP.Fail @b1_a3fH;
                             L.Punc c_a1CI [Dmd=SL] ->
                               case c_a1CI of {
                                 [] -> lvl_s5n5;
                                 : ds_d2Vb [Dmd=S!P(SL)] ds_d2Vc ->
                                   case ds_d2Vb of { C# ds_d2Vd [Dmd=SL] ->
                                   case ds_d2Vd of {
                                     __DEFAULT -> lvl_s5n5;
                                     ','# ->
                                       case ds_d2Vc of {
                                         [] ->
                                           case started_s4ge of {
                                             False -> lvl_s5n5;
                                             True -> lvl_s5n8
                                           };
                                         : ipv_s3i2 [Dmd=A] ipv_s3i3 [Dmd=A] -> lvl_s5n5
                                       };
                                     ']'# ->
                                       case ds_d2Vc of {
                                         [] -> tick<$cpure> lvl_s5na;
                                         : ipv_s3i5 [Dmd=A] ipv_s3i6 [Dmd=A] -> lvl_s5n5
                                       }
                                   }
                                   }
                               }
                           }); } in

But we generate a RULE mentioning a out of scope type variable:

Output of SpecConstr:

$wlistRest_s5qS [InlPrag=[2], Occ=LoopBreaker]
                :: Bool -> forall b. ([a_a23u] -> P b) -> P b
              [LclId,
               Arity=1,
               Str=<L>,
               RULES: "SC:$wlistRest1" [2]
                          forall. $wlistRest_s5qS True = $s$wlistRest_s5rr @b1_a3fH
                      "SC:$wlistRest0" [2]
                          forall. $wlistRest_s5qS False = $s$wlistRest_s5rq @b1_a3fH]
              $wlistRest_s5qS
                = \ (started_s4ge :: Bool) (@b1_a3fH) -> ...

Really @b1_a3fH should just be dropped by the rules RHS but clearly it isn't.

I think this is because we remove type arguments from the patterns we match on the rules left hand side.

I think the core issue is the SpecConstr implicitly assumes type variables come first in some places which goes awry here.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information