Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#8355 closed bug (duplicate)

Core lint error/warnings with `primitive-0.5.1.0`

Reported by: hvr Owned by:
Priority: highest Milestone: 7.8.1
Component: Compiler Version: 7.6.3
Keywords: Cc: bos
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: #7643 Differential Rev(s):
Wiki Page:

Description

When compiling primitive-0.5.1.0 with --ghc-option=-dcore-lint,

GHC 7.4.2 just emits a single warning:

[10 of 10] Compiling Data.Primitive.MutVar ( Data/Primitive/MutVar.hs, dist/build/Data/Primitive/MutVar.o )
*** Core Lint warnings : in result of Desugar (after optimization) ***
<no location info>:
    [RHS of $c/=_a724 :: forall s_a70h a_a70i.
                         Data.Primitive.MutVar.MutVar s_a70h a_a70i
                         -> Data.Primitive.MutVar.MutVar s_a70h a_a70i -> GHC.Types.Bool]
    INLINE binder is (non-rule) loop breaker: $c/=_a724

However, with GHC 7.6.3, an error is produced:

[ 5 of 10] Compiling Data.Primitive.Types ( Data/Primitive/Types.hs, dist/build/Data/Primitive/Types.o )
*** Core Lint errors : in result of Desugar (after optimization) ***
<no location info>: Warning:
    In the type `GHC.Prim.State# GHC.Prim.RealWorld
                 ~ GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO)'
    Kind application error in
      type `GHC.Prim.State# GHC.Prim.RealWorld
            ~ GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO)'
      Function kind = forall (k_1c :: BOX). k_1c -> k_1c -> Constraint
      Arg kinds = [(*, BOX), (GHC.Prim.State# GHC.Prim.RealWorld, #),
                   (GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO),
                    #)]
<no location info>: Warning:
    In the type `GHC.Prim.State# GHC.Prim.RealWorld
                 ~ GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO)'
    Kind application error in
      type `GHC.Prim.State# GHC.Prim.RealWorld
            ~ GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO)'
      Function kind = forall (k_1c :: BOX). k_1c -> k_1c -> Constraint
      Arg kinds = [(*, BOX), (GHC.Prim.State# GHC.Prim.RealWorld, #),
                   (GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO),
                    #)]
{-# LINE 142 "Data/Primitive/Types.hs #-}: Warning:
    [RHS of cobox_a2gR :: GHC.Prim.State# GHC.Prim.RealWorld
                          ~ GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO)]
    The type of this binder doesn't match the type of its RHS: cobox_a2gR
    Binder's type: GHC.Prim.State# GHC.Prim.RealWorld
                   ~ GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO)
    Rhs type: GHC.Prim.State# GHC.Prim.RealWorld
              ~ GHC.Prim.State# (Control.Monad.Primitive.PrimState GHC.Types.IO)

The core-lint error persists in GHC HEAD/7.7, blocking us from updating GHC's in-tree primitive/vector packages.

Attachments (1)

primitive-0.5.1.0-ghc-7.6.3.log.gz (20.6 KB) - added by hvr 6 years ago.
Full error message for GHC 7.6.3 core lint error

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by hvr

Full error message for GHC 7.6.3 core lint error

comment:1 Changed 6 years ago by monoidal

See #7643.

comment:2 Changed 6 years ago by hvr

The workaround described in #7643 seems to work w/ GHC 7.6.3 and GHC HEAD, that is:

  • Data/Primitive/Types.hs

    diff --git a/Data/Primitive/Types.hs b/Data/Primitive/Types.hs
    index ffd2cb4..cfe242c 100644
    a b instance Prim ty where { \ 
    114114                        { (# s1#, x# #) -> (# s1#, ctr x# #) }  \
    115115; writeByteArray# arr# i# (ctr x#) s# = wr_arr arr# i# x# s#    \
    116116; setByteArray# arr# i# n# (ctr x#) s#                          \
    117     = case internal (set_arr arr# i# n# x#) (unsafeCoerce# s#) of \
    118         { (# s1#, _ #) -> unsafeCoerce# s1# }                   \
     117    = case unsafeCoerce# (internal (set_arr arr# i# n# x#)) s# of \
     118        { (# s1#, _ #) -> s1# }                                 \
    119119                                                                \
    120120; indexOffAddr# addr# i# = ctr (idx_addr addr# i#)              \
    121121; readOffAddr#  addr# i# s# = case rd_addr addr# i# s# of       \
    122122                        { (# s1#, x# #) -> (# s1#, ctr x# #) }  \
    123123; writeOffAddr# addr# i# (ctr x#) s# = wr_addr addr# i# x# s#   \
    124124; setOffAddr# addr# i# n# (ctr x#) s#                           \
    125     = case internal (set_addr addr# i# n# x#) (unsafeCoerce# s#) of \
    126         { (# s1#, _ #) -> unsafeCoerce# s1# }                   \
     125    = case unsafeCoerce# (internal (set_addr addr# i# n# x#)) s# of \
     126        { (# s1#, _ #) -> s1# }                                 \
    127127; {-# INLINE sizeOf# #-}                                        \
    128128; {-# INLINE alignment# #-}                                     \
    129129; {-# INLINE indexByteArray# #-}                                \

I'll run a few tests and validate; if that works out I'll file a pull-request at http://github.com/haskell/primitive

comment:3 Changed 6 years ago by hvr

Resolution: duplicate
Status: newclosed

Actually a duplicate of #7643

comment:4 Changed 6 years ago by Herbert Valerio Riedel <hvr@…>

In 5e2f145a3737b8ff81445ffbe3dd72d8985d608e/ghc:

Update `primitive` and `vector` packages

 - `primitive` is updated to upstream's HEAD which is essentially
   `primitive-0.5.1.0`, plus a core-lint-error workaround for #8355 and
   some minor cleanups.

 - `vector` is updated to upstreams `vector-0.10.9.1` release

Note: The upstream repo location has changed to GitHub,
      hence the update in the `packages` file

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
Note: See TracTickets for help on using tickets.