-
Simon Peyton Jones authored
Crikey! Not just one but two bugs in type variable cloning, both dating from the days before PolyKinds. Both were shown up by Trac #11330. 1. In SetLevels, when floating a case expression we must clone its binders, *and* do so in a telescope-aware way, because the constructor may bind a kind variable that appears in the kind of a type variable. Instead of doing this (wrongly) by steam, call CoreSubst.cloneBndrs. I added Notes and did other refactoring at the same time. 2. It turned out that CoreSubst.cloneBndrs calls TyCoRep.cloneTyVarBndr, and that too was bogus! It didn't substitute in the kind of the TyVar being cloned. There was even a comment to say "variables can't appear in kinds". Thta hasn't been true for a long time now. Easily fixed. Interestingly, I then found that test dependent/should_compile/KindEqualities was emitting a new inexhaustive-pattern-match warning. Sure enough it was valid! So the lack of cloning in cloneTyVarBndr really was causing an observable bug; just one that we had not observed.
016a0bd1