Commit 9bcbb222 authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari
Browse files

Fix #15308 by suppressing invisble args more rigorously

There was a buglet in `stripInvisArgs` (which is part of the
pretty-printing pipeline for types) in which only invisble arguments
which came before any visible arguments would be suppressed, but any
invisble arguments that came //after// visible ones would still be
printed, even if `-fprint-explicit-kinds`  wasn't enabled.
The fix is simple: make `stripInvisArgs` recursively process the
remaining types even after a visible argument is encountered.

Test Plan: make test TEST=T15308

Reviewers: goldfire, bgamari

Reviewed By: bgamari

Subscribers: simonpj, rwbarton, thomie, carter

GHC Trac Issues: #15308

Differential Revision:

(cherry picked from commit 93b7ac8d)
parent 42396113
......@@ -513,8 +513,13 @@ stripInvisArgs dflags tys
suppress_invis c
= case c of
ITC_Nil -> ITC_Nil
ITC_Invis _ ts -> suppress_invis ts
_ -> c
ITC_Vis t ts -> ITC_Vis t $ suppress_invis ts
-- Keep recursing through the remainder of the arguments, as it's
-- possible that there are remaining invisible ones.
-- See the "In type declarations" section of Note [TyVarBndrs,
-- TyVarBinders, TyConBinders, and visibility] in TyCoRep.
tcArgsIfaceTypes :: IfaceTcArgs -> [IfaceType]
tcArgsIfaceTypes ITC_Nil = []
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeInType #-}
module T15308 where
import Data.Kind
data Foo (a :: Type) :: forall b. (a -> b -> Type) -> Type where
MkFoo :: Foo a f
f :: Foo a f -> String
f = show
T15308.hs:12:5: error:
• No instance for (Show (Foo a f)) arising from a use of ‘show’
• In the expression: show
In an equation for ‘f’: f = show
......@@ -32,3 +32,4 @@ test('T14845_fail2', normal, compile_fail, [''])
test('InferDependency', normal, compile_fail, [''])
test('T15245', normal, compile_fail, [''])
test('T15215', normal, compile_fail, [''])
test('T15308', normal, compile_fail, ['-fno-print-explicit-kinds'])
......@@ -11,7 +11,7 @@ T12785b.hs:29:63: error:
‘s’ is a rigid type variable bound by
a pattern with constructor:
Hide :: forall a (n :: Peano) (f :: a -> *) (s :: HTree n a).
STree n a f s -> Hidden n f,
STree n f s -> Hidden n f,
in an equation for ‘nest’
at T12785b.hs:29:7-12
• In the second argument of ‘($)’, namely ‘a `SBranchX` tr’
......@@ -20,12 +20,8 @@ T12785b.hs:29:63: error:
nest (Hide a `Branch` (nest . hmap nest -> Hide tr))
= Hide $ a `SBranchX` tr
• Relevant bindings include
tr :: STree
(HTree ('S n) (HTree ('S ('S n)) a))
(STree ('S n) (HTree ('S ('S n)) a) (STree ('S ('S n)) a f))
tr :: STree n (STree ('S n) (STree ('S ('S n)) f)) s1
(bound at T12785b.hs:29:49)
a :: STree ('S m) a f s (bound at T12785b.hs:29:12)
nest :: HTree m (Hidden ('S m) f) -> Hidden m (STree ('S m) a f)
a :: STree ('S m) f s (bound at T12785b.hs:29:12)
nest :: HTree m (Hidden ('S m) f) -> Hidden m (STree ('S m) f)
(bound at T12785b.hs:27:1)
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