Commit c751082c authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

testsuite: Make ExplicitForAllRules1 more robust

Previously the test relied on `id` not inlining. Fix this.
parent 51067194
......@@ -14,20 +14,24 @@ import Data.Kind
{-# RULES
"example" forall a b. forall. map @a @b f = f
"example2" forall a. forall (x :: a). id x = x
"example2" forall a. forall (x :: a). id' x = x
#-}
{-# NOINLINE f #-}
f :: a -> b
f = undefined
id' :: a -> a
id' x = x
{-# NOINLINE id' #-}
-- More tests
{-# RULES
"example3" forall (a :: Type -> Type) (b :: a Int) c. forall x y. g @(Proxy b) @(Proxy c) x y = ()
"example4" forall (a :: Bool) (b :: Proxy a). forall x. g @(Proxy b) @() x = id @()
"example5" forall (a :: Type). forall. h @a = id @a
"example5" forall k (c :: k). forall (x :: Proxy c). id @(Proxy c) x = x
"example4" forall (a :: Bool) (b :: Proxy a). forall x. g @(Proxy b) @() x = id' @()
"example5" forall (a :: Type). forall. h @a = id' @a
"example5" forall k (c :: k). forall (x :: Proxy c). id' @(Proxy c) x = x
#-}
{-# NOINLINE g #-}
......@@ -42,4 +46,4 @@ h x = x
{-# RULES "example6" forall a forall. g a forall = () #-}
-- Should generate a warning
{-# RULES "example7" forall a b. forall (x :: a). id x = x #-}
{-# RULES "example7" forall a b. forall (x :: a). id' x = x #-}
ExplicitForAllRules1.hs:45:11: warning:
ExplicitForAllRules1.hs:49:11: warning:
Forall'd type variable ‘k’ is not bound in RULE lhs
Orig bndrs: [k, a, b, x]
Orig lhs: id @ a x
optimised lhs: id @ a x
Orig lhs: id' @ a x
optimised lhs: id' @ a x
Forall'd type variable ‘b’ is not bound in RULE lhs
Orig bndrs: [k, a, b, x]
Orig lhs: id @ a x
optimised lhs: id @ a x
Orig lhs: id' @ a x
optimised lhs: id' @ a x
ExplicitForAllRules1.hs:45:31: warning: [-Wunused-foralls (in -Wextra)]
ExplicitForAllRules1.hs:49:31: warning: [-Wunused-foralls (in -Wextra)]
Unused quantified type variable ‘b’
in the rule "example7"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment