Skip to content

loopbreaker test suite failure on ghc 8.8, doesn't break recursion in let/where bindings? #10

@DanBurton

Description

@DanBurton

I was able to reproduce this locally like so:

stack unpack loopbreaker-0.1.1.1 && cd loopbreaker-0.1.1.1
echo 'resolver: nightly-2019-11-20' > stack.yaml
stack build --test --bench --no-run-benchmarks --fast

Here's the log output

DisableFlag
  plugin
    should respect disable flag
InlineRecCalls
  plugin
    should explicitly break recursion in global bindings
    should explicitly break recursion in where bindings FAILED [1]
    should explicitly break recursion in let bindings FAILED [2]
PragmaDetection
  plugin
    should respect INLINE pragma

Failures:

  test/TestUtils.hs:14:56:
  1) InlineRecCalls.plugin should explicitly break recursion in where bindings
       uncaught exception: ErrorCall
       test/InlineRecCallsSpec.hs:20:21: localRecursiveWhere === localMutual failed:
           LHS:
               localRecursiveWhere :: Int -> Int
               [LclIdX,
                Arity=1,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 60}]
               localRecursiveWhere = local @ Int $fEqInt $fNumInt

               lvl_saou :: Integer
               [LclId,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}]
               lvl_saou = 1

               lvl_saos :: Integer
               [LclId,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}]
               lvl_saos = 0

               local [InlPrag=INLINE (sat-args=1)]
                 :: forall p. (Eq p, Num p) => p -> p
               [LclId,
                Arity=3,
                Str=<S(C(C(S))L),U(C(C1(U)),A)><L,U(A,C(C1(U)),C(C1(U)),A,A,A,C(U))><L,U>,
                Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True,
                        Guidance=ALWAYS_IF(arity=3,unsat_ok=False,boring_ok=False)
                        Tmpl= \ (@ p)
                                ($dEq_a9Yo [Occ=OnceL] :: Eq p)
                                ($dNum_a9Yp :: Num p) ->
                                letrec {
                                  local [Occ=LoopBreaker] :: p -> p
                                  [LclId,
                                   Arity=1,
                                   Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                                           WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 550 0}]
                                  local
                                    = \ (ds_dajc :: p) ->
                                        case == @ p $dEq_a9Yo ds_dajc (fromInteger @ p $dNum_a9Yp 0) of {
                                          False ->
                                            * @ p
                                              $dNum_a9Yp
                                              ds_dajc
                                              (local
                                                 (- @ p
                                                    $dNum_a9Yp
                                                    ds_dajc
                                                    (fromInteger @ p $dNum_a9Yp 1)));
                                          True -> fromInteger @ p $dNum_a9Yp 1
                                        }; } in
                                local}]
               local
                 = \ (@ p)
                     ($dEq_a9Yo [Dmd=<S(C(C(S))L),U(C(C1(U)),A)>] :: Eq p)
                     ($dNum_a9Yp [Dmd=<L,U(A,C(C1(U)),C(C1(U)),A,A,A,C(U))>] :: Num p)
                     (eta_B1 :: p) ->
                     let {
                       lvl_saoD :: p
                       [LclId,
                        Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
                                WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}]
                       lvl_saoD = fromInteger @ p $dNum_a9Yp lvl_saou } in
                     let {
                       lvl_saoz :: p
                       [LclId,
                        Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
                                WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}]
                       lvl_saoz = fromInteger @ p $dNum_a9Yp lvl_saos } in
                     letrec {
                       local [Occ=LoopBreaker] :: p -> p
                       [LclId,
                        Arity=1,
                        Str=<L,U> {a9Yo-><S(C(C(S))L),U(C(C1(U)),A)>},
                        Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                                WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 160 0}]
                       local
                         = \ (ds_dajc :: p) ->
                             case == @ p $dEq_a9Yo ds_dajc lvl_saoz of {
                               False ->
                                 * @ p
                                   $dNum_a9Yp
                                   ds_dajc
                                   (local (- @ p $dNum_a9Yp ds_dajc lvl_saoD));
                               True -> lvl_saoD
                             }; } in
                     local eta_B1

           RHS:
               localMutual [InlPrag=INLINE (sat-args=1)] :: Int -> Int
               [LclIdX,
                Arity=1,
                Str=<S(S),1*U(1*U)>,
                Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True,
                        Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=True)
                        Tmpl= local}]
               localMutual = local

               lvl_saol :: Int
               [LclId,
                Str=m,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
               lvl_saol = I# 1#

               $wlocal [InlPrag=NOUSERINLINE[2], Occ=LoopBreaker] :: Int# -> Int
               [LclId,
                Arity=1,
                Str=<S,1*U>,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [30] 150 0}]
               $wlocal
                 = \ (ww_sar7 [Dmd=<S,1*U>] :: Int#) ->
                     case ww_sar7 of ds_Xajd {
                       __DEFAULT ->
                         let {
                           wild_Xo :: Int
                           [LclId,
                            Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                                    WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
                           wild_Xo = I# ds_Xajd } in
                         * @ Int
                           $fNumInt
                           wild_Xo
                           (case - @ Int $fNumInt wild_Xo lvl_saol of
                            { I# ww_Xash [Dmd=<S,1*U>] ->
                            $wlocal ww_Xash
                            });
                       0# -> lvl_saol
                     }

               local [InlPrag=NOUSERINLINE[2]] :: Int -> Int
               [LclId,
                Arity=1,
                Str=<S(S),1*U(1*U)>,
                Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True,
                        Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
                        Tmpl= \ (w_sar4 [Occ=Once!] :: Int) ->
                                case w_sar4 of { I# ww_sar7 [Occ=Once, Dmd=<S,U>] ->
                                $wlocal ww_sar7
                                }}]
               local
                 = \ (w_sar4 [Dmd=<S(S),1*U(1*U)>] :: Int) ->
                     case w_sar4 of { I# ww_sar7 [Dmd=<S,1*U>] -> $wlocal ww_sar7 }

       CallStack (from HasCallStack):
         error, called at test/TestUtils.hs:14:56 in main:TestUtils

  To rerun use: --match "/InlineRecCalls/plugin/should explicitly break recursion in where bindings/"

  test/TestUtils.hs:14:56:
  2) InlineRecCalls.plugin should explicitly break recursion in let bindings
       uncaught exception: ErrorCall
       test/InlineRecCallsSpec.hs:22:21: localRecursiveLet === localMutual failed:
           LHS:
               localRecursiveLet :: Int -> Int
               [LclIdX,
                Arity=1,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 30 60}]
               localRecursiveLet = local @ Int $fEqInt $fNumInt

               lvl_saou :: Integer
               [LclId,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}]
               lvl_saou = 1

               lvl_saos :: Integer
               [LclId,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 100 0}]
               lvl_saos = 0

               local [InlPrag=INLINE (sat-args=1)]
                 :: forall p. (Eq p, Num p) => p -> p
               [LclId,
                Arity=3,
                Str=<S(C(C(S))L),U(C(C1(U)),A)><L,U(A,C(C1(U)),C(C1(U)),A,A,A,C(U))><L,U>,
                Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True,
                        Guidance=ALWAYS_IF(arity=3,unsat_ok=False,boring_ok=False)
                        Tmpl= \ (@ p)
                                ($dEq_a9XA [Occ=OnceL] :: Eq p)
                                ($dNum_a9XB :: Num p) ->
                                letrec {
                                  local [Occ=LoopBreaker] :: p -> p
                                  [LclId,
                                   Arity=1,
                                   Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                                           WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 550 0}]
                                  local
                                    = \ (ds_daj6 :: p) ->
                                        case == @ p $dEq_a9XA ds_daj6 (fromInteger @ p $dNum_a9XB 0) of {
                                          False ->
                                            * @ p
                                              $dNum_a9XB
                                              ds_daj6
                                              (local
                                                 (- @ p
                                                    $dNum_a9XB
                                                    ds_daj6
                                                    (fromInteger @ p $dNum_a9XB 1)));
                                          True -> fromInteger @ p $dNum_a9XB 1
                                        }; } in
                                local}]
               local
                 = \ (@ p)
                     ($dEq_a9XA [Dmd=<S(C(C(S))L),U(C(C1(U)),A)>] :: Eq p)
                     ($dNum_a9XB [Dmd=<L,U(A,C(C1(U)),C(C1(U)),A,A,A,C(U))>] :: Num p)
                     (eta_B1 :: p) ->
                     let {
                       lvl_saox :: p
                       [LclId,
                        Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
                                WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}]
                       lvl_saox = fromInteger @ p $dNum_a9XB lvl_saou } in
                     let {
                       lvl_saot :: p
                       [LclId,
                        Unf=Unf{Src=<vanilla>, TopLvl=False, Value=False, ConLike=False,
                                WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 30 0}]
                       lvl_saot = fromInteger @ p $dNum_a9XB lvl_saos } in
                     letrec {
                       local [Occ=LoopBreaker] :: p -> p
                       [LclId,
                        Arity=1,
                        Str=<L,U> {a9XA-><S(C(C(S))L),U(C(C1(U)),A)>},
                        Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                                WorkFree=True, Expandable=True, Guidance=IF_ARGS [0] 160 0}]
                       local
                         = \ (ds_daj6 :: p) ->
                             case == @ p $dEq_a9XA ds_daj6 lvl_saot of {
                               False ->
                                 * @ p
                                   $dNum_a9XB
                                   ds_daj6
                                   (local (- @ p $dNum_a9XB ds_daj6 lvl_saox));
                               True -> lvl_saox
                             }; } in
                     local eta_B1

           RHS:
               localMutual [InlPrag=INLINE (sat-args=1)] :: Int -> Int
               [LclIdX,
                Arity=1,
                Str=<S(S),1*U(1*U)>,
                Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True,
                        Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=True)
                        Tmpl= local}]
               localMutual = local

               lvl_saol :: Int
               [LclId,
                Str=m,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
               lvl_saol = I# 1#

               $wlocal [InlPrag=NOUSERINLINE[2], Occ=LoopBreaker] :: Int# -> Int
               [LclId,
                Arity=1,
                Str=<S,1*U>,
                Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True, Guidance=IF_ARGS [30] 150 0}]
               $wlocal
                 = \ (ww_sar7 [Dmd=<S,1*U>] :: Int#) ->
                     case ww_sar7 of ds_Xajd {
                       __DEFAULT ->
                         let {
                           wild_Xo :: Int
                           [LclId,
                            Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                                    WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
                           wild_Xo = I# ds_Xajd } in
                         * @ Int
                           $fNumInt
                           wild_Xo
                           (case - @ Int $fNumInt wild_Xo lvl_saol of
                            { I# ww_Xash [Dmd=<S,1*U>] ->
                            $wlocal ww_Xash
                            });
                       0# -> lvl_saol
                     }

               local [InlPrag=NOUSERINLINE[2]] :: Int -> Int
               [LclId,
                Arity=1,
                Str=<S(S),1*U(1*U)>,
                Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
                        WorkFree=True, Expandable=True,
                        Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=False)
                        Tmpl= \ (w_sar4 [Occ=Once!] :: Int) ->
                                case w_sar4 of { I# ww_sar7 [Occ=Once, Dmd=<S,U>] ->
                                $wlocal ww_sar7
                                }}]
               local
                 = \ (w_sar4 [Dmd=<S(S),1*U(1*U)>] :: Int) ->
                     case w_sar4 of { I# ww_sar7 [Dmd=<S,1*U>] -> $wlocal ww_sar7 }

       CallStack (from HasCallStack):
         error, called at test/TestUtils.hs:14:56 in main:TestUtils

  To rerun use: --match "/InlineRecCalls/plugin/should explicitly break recursion in let bindings/"

Randomized with seed 1398579975

Finished in 0.0139 seconds
5 examples, 2 failures

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions