Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflected function on GADT needs explicit type annotation #1422

Open
rosekunkel opened this issue Mar 14, 2019 · 1 comment
Open

Reflected function on GADT needs explicit type annotation #1422

rosekunkel opened this issue Mar 14, 2019 · 1 comment

Comments

@rosekunkel
Copy link
Contributor

The following triggers an LH error:

{-# LANGUAGE GADTs #-}
{-@ LIQUID "--reflection" @-}

module Gadt where

data Foo a where
  Bar :: Foo Int
  Baz :: Foo Bool

{-@ reflect getFoo @-}
getFoo :: Foo a -> a
getFoo Bar = 123
getFoo Baz = True

The error is

Error: Illegal type specification for `Gadt.getFoo`
  
 11 | {-@ reflect getFoo @-}
                  ^^^^^^
  
     Gadt.getFoo :: forall a##xo .
                    lq1:(Gadt.Foo a##xo)
                    -> {VV : a##xo | VV == getFoo lq1}
     Sort Error in Refinement: {VV : a##aWl | (VV == Gadt.getFoo lq1
                                               && VV == (if is$Gadt.Bar lq1 then GHC.Num.fromInteger (coerce (GHC.Num.Num int) ~ (GHC.Num.Num a##aWl) in GHC.Num.$fNumInt) 123 else (coerce bool ~ a##aWl in true)))}
     Unbound symbol GHC.Num.fromInteger --- perhaps you meant: GHC.Types.IntRep, GHC.Enum.C:Bounded, GHC.Real.C:Integral ?

However, if we explicitly annotate the type of 123, it passes:

{-# LANGUAGE GADTs #-}
{-@ LIQUID "--reflection" @-}

module Gadt where

data Foo a where
  Bar :: Foo Int
  Baz :: Foo Bool

{-@ reflect getFoo @-}
getFoo :: Foo a -> a
getFoo Bar = 123 :: Int
getFoo Baz = True
@ranjitjhala
Copy link
Member

ranjitjhala commented Mar 15, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants