Use the right in-scope set
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 5 Jan 2017 17:39:08 +0000 (17:39 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 6 Jan 2017 09:36:20 +0000 (09:36 +0000)
I tripped over these calls to substTyWith that didn't obey the
precondition about in-scope variables.  Easily fixed, happily.

compiler/coreSyn/CoreLint.hs

index 79e577a..1eacd73 100644 (file)
@@ -1488,13 +1488,14 @@ lintCoercion (InstCo co arg)
   = do { (k3, k4, t1',t2', r) <- lintCoercion co
        ; (k1',k2',s1,s2, r') <- lintCoercion arg
        ; lintRole arg Nominal r'
+       ; in_scope <- getInScope
        ; case (splitForAllTy_maybe t1', splitForAllTy_maybe t2') of
           (Just (tv1,t1), Just (tv2,t2))
             | k1' `eqType` tyVarKind tv1
             , k2' `eqType` tyVarKind tv2
             -> return (k3, k4,
-                       substTyWith [tv1] [s1] t1,
-                       substTyWith [tv2] [s2] t2, r)
+                       substTyWithInScope in_scope [tv1] [s1] t1,
+                       substTyWithInScope in_scope [tv2] [s2] t2, r)
             | otherwise
             -> failWithL (text "Kind mis-match in inst coercion")
           _ -> failWithL (text "Bad argument of inst") }