ucsd-progsys / liquidhaskell

Liquid Types For Haskell
BSD 3-Clause "New" or "Revised" License
1.19k stars 137 forks source link

`autosize` fails on abstractly-refined, instance-deriving data #896

Open awstlaur opened 7 years ago

awstlaur commented 7 years ago
{-@ autosize List @-}

{-@ data List a <p :: a -> Prop>
      = N | C {hd :: a<p>, tl :: List a}
  @-}
data List a = N | C a (List a)
    deriving (Eq)
**** RESULT: ERROR *************************************************************

 <no location info>: Error: Uh oh.
     Constraint.instanctiatePv

If we remove the deriving (Eq) part, or if we remove the abstract refinement (below), then there is no error.

{-@ autosize List @-}

{-@ data List a
      = N | C {hd :: a, tl :: (List a)}
  @-}
data List a = N | C a (List a)
    deriving (Eq)
**** RESULT: SAFE **************************************************************
nikivazou commented 7 years ago

Thanks!

Does the easy work around work? To define the Eq instance yourself (for now).

awstlaur commented 7 years ago

Yes that will definitely work. (In fact, I probably won't even be using autosize after all; I was mostly curious and then stumbled into this.)

ranjitjhala commented 7 years ago

Thanks for pointing this out!