Error when trying to lift a function invoking another function
josedusol opened this issue · comments
Hello. Newbie playing with LH, and having some problems. Consider the following code recreating the Bool type and some related functions:
module MyBool where
import Prelude hiding (Bool,not)
data Bool where
F :: Bool
T :: Bool
deriving (Show)
{-@ not :: Bool -> Bool @-}
not :: Bool -> Bool
not F = T
not T = F
{-@ infixr 1 === @-}
{-@ inline === @-} -- LH doesnt like this
{-@ (===) :: Bool -> Bool -> Bool @-}
(===) :: Bool -> Bool -> Bool
F === b2 = b2
T === b2 = not b2 -- no problem if we omit 'not'
This gives me the following error:
* Illegal type specification for `MyBool.===` MyBool.=== :: lq_tmp$db##0:MyBool.Bool -> lq_tmp$db##1:MyBool.Bool -> {VV : MyBool.Bool | VV == (if is$MyBool.F lq_tmp$db##0 then lq_tmp$db##1 else not lq_tmp$db##1)} Sort Error in Refinement: {VV : MyBool.Bool | VV == (if is$MyBool.F lq_tmp$db##0 then lq_tmp$db##1 else not lq_tmp$db##1)} Expressions lq_tmp$db##1 should have bool sort, but has MyBool.Bool Just *
reflect
also doesnt work, the error is similar. More in general, it seems i can't lift to the logic a function wich invokes another function (lifted or not). What is the cause of this?.
Using ghc-9.0.2, liquidhaskell-0.9.0.2 and liquid-base-4.15.1.0.
👋 Name resolution is failing there when inlining. If not
is renamed to not_
, LH starts complaining that not_
is not in scope. Which then prompts to add {-@ inline not_ @-}
, which then gets LH happy (but note that I'm testing it in the unreleased version from github).
My take is that in the original program, LH is picking Prelude.not
despite the import declaration. This is clearly not what any user would expect, so it is worth fixing it. But it might not be the simplest contribution to make.
Name resolution is not solid in general. When redefining names in terms or types, awareness of this might help the diagnose.
Thanks for the workaround. Using different names fixed the issue.