Skip to content

Core Lint error with -fdefer-type-errors and bad RULE

To reproduce:

module T24026 where

{-# RULES "f" forall (x :: Bool). f x = 0 #-}

f :: Int -> Int
f x = 0
$ ghc -dlint -fdefer-type-errors T24026
[1 of 1] Compiling T24026           ( T24026.hs, T24026.o )
*** Core Lint errors : in result of Desugar (before optimization) ***
T24026.hs:6:1: warning:
    The coercion variable co_awP :: Bool ~# Int
                          [LclId[CoVarId]]
      is out of scope
    In the RHS of f :: Int -> Int
    In a rule attached to f :: Int -> Int
    Substitution: <InScope = {}
                   IdSubst   = []
                   TvSubst   = []
                   CvSubst   = []>
*** Offending Program ***
Rec {
$trModule :: Module
[LclIdX]
$trModule = Module (TrNameS "main"#) (TrNameS "T24026"#)

f :: Int -> Int
[LclIdX,
 RULES: "f" forall (x_awv :: Bool).
              f (x_awv `cast` (Sub co_awP :: Bool ~R# Int))
              = I# 0#]
f = \ (x_awu :: Int) -> I# 0#
end Rec }

The RULE has a type error, the coercion Int ~ Bool from -fdefer-type-errors is not bound.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information