tweag / ghc

Fork of official GHC repository.
http://www.haskell.org/ghc/
Other
44 stars 5 forks source link

cgrun049 fails with a core lint error #50

Closed mpickering closed 6 years ago

mpickering commented 6 years ago

The error occurs as follows:

[1 of 1] Compiling Main             ( linear-tests/anf.hs, linear-tests/anf.o )
*** Core Lint errors : in result of Simplifier ***
<no location info>: warning:
    In a case alternative: (I# dt_a1hr[ω] :: Int#)
    Linearity failure in lambda: dt_X1hw[1]
    ω ⊈ 1
*** Offending Program ***
f[ω] [InlPrag=NOINLINE] :: T -> T
[LclId,
 Arity=1,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [20] 110 50}]
f[ω]
  = \ (ds_d1KV[ω] :: T) ->
      case ds_d1KV[ω] of
      { MkT x_a12d[ω] dt_d1ZQ[ω] ds_d1L8[ω] ds_d1L9[ω] ->
      case ds_d1L8[ω] of { (a_s3oH[ω], b_s3oI[ω]) ->
      case ds_d1L9[ω] of { MkS p_s3oL[ω] q_s3oM[ω] ->
      case b_s3oI[ω] of { I# dt_a1hr[ω] ->
      let {
        dt_X1hw[1] :: (Int, Int)
        [LclId,
         Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                 WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
        dt_X1hw[1] = (p_s3oL[ω], q_s3oM[ω]) } in
      let {
        dt_s3p3[ω] :: Int
        [LclId,
         Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                 WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
        dt_s3p3[ω] = I#[ω] dt_d1ZQ[ω] } in
      let {
        dt_X1hy[1] :: S Int
        [LclId,
         Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                 WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
        dt_X1hy[1] = MkS[ω] @ Int x_a12d[ω] dt_s3p3[ω] } in
      MkT[ω] a_s3oH[ω] dt_a1hr[ω] dt_X1hw[1] dt_X1hy[1]
      }
      }
      }
      }

main_s20m[ω] :: String
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
         WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 240 30}]
main_s20m[ω]
  = case f[ω]
           (let {
              dt_s3p4[ω] :: Int
              [LclId,
               Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                       WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
              dt_s3p4[ω] = I#[ω] 3# } in
            let {
              dt_s3p5[ω] :: Int
              [LclId,
               Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                       WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
              dt_s3p5[ω] = I#[ω] 4# } in
            let {
              dt_X1hw[1] :: (Int, Int)
              [LclId,
               Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                       WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
              dt_X1hw[1] = (dt_s3p4[ω], dt_s3p5[ω]) } in
            let {
              dt_s3p6[ω] :: Int
              [LclId,
               Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                       WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
              dt_s3p6[ω] = I#[ω] 5# } in
            let {
              dt_s3p7[ω] :: Int
              [LclId,
               Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                       WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
              dt_s3p7[ω] = I#[ω] 6# } in
            let {
              dt_X1hy[1] :: S Int
              [LclId,
               Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
                       WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
              dt_X1hy[1] = MkS[ω] @ Int dt_s3p6[ω] dt_s3p7[ω] } in
            MkT[ω] (I#[ω] 1#) 2# dt_X1hw[1] dt_X1hy[1])
    of
    { MkT x_a12c[ω] dt_d1ZR[ω] ds_d1Lm[ω] ds_d1Ln[ω] ->
    case x_a12c[ω] of { I# ww3_a20e[ω] ->
    case $wshowSignedInt[ω] 0# ww3_a20e[ω] ([][ω] @ Char) of
    { (# ww5_a20i[ω], ww6_a20j[ω] #) ->
    :[ω] @ Char ww5_a20i[ω] ww6_a20j[ω]
    }
    }
    }

main[ω] :: IO ()
[LclIdX,
 Arity=1,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 40 60}]
main[ω] = hPutStr'[ω] stdout[ω] main_s20m[ω] True[ω]

main_s3oh[ω] :: State# RealWorld -> (# State# RealWorld, () #)
[LclId,
 Arity=1,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 60}]
main_s3oh[ω] = runMainIO1[ω] @ () main[ω]

main[ω] :: IO ()
[LclIdX,
 Arity=1,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True,
         Guidance=ALWAYS_IF(arity=0,unsat_ok=True,boring_ok=True)}]
main[ω]
  = main_s3oh[ω]
    `cast` (Sym (N:IO[0] <()>_R)
            :: (State# RealWorld -> (# State# RealWorld, () #) :: *)
               ~R# (IO () :: *))

$trModule_s3oi[ω] :: Addr#
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
$trModule_s3oi[ω] = "main"#

$trModule_s3oj[ω] :: TrName
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$trModule_s3oj[ω] = TrNameS[ω] $trModule_s3oi[ω]

$trModule_s3ok[ω] :: Addr#
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
$trModule_s3ok[ω] = "Main"#

$trModule_s3ol[ω] :: TrName
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$trModule_s3ol[ω] = TrNameS[ω] $trModule_s3ok[ω]

$trModule[ω] :: Module
[LclIdX,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$trModule[ω] = Module[ω] $trModule_s3oj[ω] $trModule_s3ol[ω]

$krep_a1KE[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KE[ω] = KindRepTyConApp[ω] $tcInt[ω] ([][ω] @ KindRep)

$krep_s3om[ω] :: [KindRep]
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_s3om[ω] = :[ω] @ KindRep $krep_a1KE[ω] ([][ω] @ KindRep)

$krep_s3on[ω] :: [KindRep]
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_s3on[ω] = :[ω] @ KindRep $krep_a1KE[ω] $krep_s3om[ω]

$krep_a1KH[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KH[ω] = KindRepTyConApp[ω] $tc(,)[ω] $krep_s3on[ω]

$krep_a1KM[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$krep_a1KM[ω] = KindRepVar[ω] 0#

$tcS_s3oo[ω] :: Addr#
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
$tcS_s3oo[ω] = "S"#

$tcS_s3op[ω] :: TrName
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$tcS_s3op[ω] = TrNameS[ω] $tcS_s3oo[ω]

$tcS[ω] :: TyCon
[LclIdX,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}]
$tcS[ω]
  = TyCon[ω]
      12358882210102579071##
      11732409912502843608##
      $trModule[ω]
      $tcS_s3op[ω]
      0#
      krep$*Arr*[ω]

$krep_s3oq[ω] :: [KindRep]
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_s3oq[ω] = :[ω] @ KindRep $krep_a1KM[ω] ([][ω] @ KindRep)

$krep_a1KO[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KO[ω] = KindRepTyConApp[ω] $tcS[ω] $krep_s3oq[ω]

$krep_a1KN[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KN[ω] = KindRepFun[ω] $krep_a1KM[ω] $krep_a1KO[ω]

$krep_a1KL[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KL[ω] = KindRepFun[ω] $krep_a1KM[ω] $krep_a1KN[ω]

$tc'MkS_s3or[ω] :: Addr#
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
$tc'MkS_s3or[ω] = "'MkS"#

$tc'MkS_s3os[ω] :: TrName
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$tc'MkS_s3os[ω] = TrNameS[ω] $tc'MkS_s3or[ω]

$tc'MkS[ω] :: TyCon
[LclIdX,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}]
$tc'MkS[ω]
  = TyCon[ω]
      5681534714276734043##
      2564534766829981032##
      $trModule[ω]
      $tc'MkS_s3os[ω]
      1#
      $krep_a1KL[ω]

$krep_s3ot[ω] :: [KindRep]
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_s3ot[ω] = :[ω] @ KindRep $krep_a1KE[ω] ([][ω] @ KindRep)

$krep_a1KJ[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KJ[ω] = KindRepTyConApp[ω] $tcS[ω] $krep_s3ot[ω]

$tcT_s3ou[ω] :: Addr#
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
$tcT_s3ou[ω] = "T"#

$tcT_s3ov[ω] :: TrName
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$tcT_s3ov[ω] = TrNameS[ω] $tcT_s3ou[ω]

$tcT[ω] :: TyCon
[LclIdX,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}]
$tcT[ω]
  = TyCon[ω]
      2034151975083080021##
      13309473083653564432##
      $trModule[ω]
      $tcT_s3ov[ω]
      0#
      krep$*[ω]

$krep_a1KK[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KK[ω] = KindRepTyConApp[ω] $tcT[ω] ([][ω] @ KindRep)

$krep_a1KI[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KI[ω] = KindRepFun[ω] $krep_a1KJ[ω] $krep_a1KK[ω]

$krep_a1KG[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KG[ω] = KindRepFun[ω] $krep_a1KH[ω] $krep_a1KI[ω]

$krep_a1KF[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KF[ω] = KindRepFun[ω] $krep_a1KE[ω] $krep_a1KG[ω]

$krep_a1KD[ω] [InlPrag=NOUSERINLINE[~]] :: KindRep
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 30}]
$krep_a1KD[ω] = KindRepFun[ω] $krep_a1KE[ω] $krep_a1KF[ω]

$tc'MkT_s3ow[ω] :: Addr#
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 0}]
$tc'MkT_s3ow[ω] = "'MkT"#

$tc'MkT_s3ox[ω] :: TrName
[LclId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 20}]
$tc'MkT_s3ox[ω] = TrNameS[ω] $tc'MkT_s3ow[ω]

$tc'MkT[ω] :: TyCon
[LclIdX,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 10 70}]
$tc'MkT[ω]
  = TyCon[ω]
      3703905455809284232##
      14916338316586523079##
      $trModule[ω]
      $tc'MkT_s3ox[ω]
      0#
      $krep_a1KD[ω]

*** End of Offense ***
mpickering commented 6 years ago

There are several contributing factors to the problem.

  1. The data constructor MkT has a wrapper $WMkT which has linear arguments. Thus when $WMkT is beta reduced, the let bound variables are linear.
  2. prepareRhs then transforms xy[1] = (5. 6) into d1[w] = 5; d2[w] = 6; xy[1] = (d1, d2). This happens in a nested manner -- then the usage of xy ends up being multiplied by w which results in the core lint error.

I don't know what the correct way to fix this is so I am going to punt it for now.

aspiwack commented 6 years ago

As far as I can tell, this has been long fixed.