Remove the type-checking knot.
Bug #15380 hangs because a knot-tied TyCon ended up in a kind. Looking at the code in tcInferApps, I'm amazed this hasn't happened before! I couldn't think of a good way to fix it (with dependent types, we can't really keep types out of kinds, after all), so I just went ahead and removed the knot. This was remarkably easy to do. In tcTyVar, when we find a TcTyCon, just use it. (Previously, we looked up the knot-tied TyCon and used that.) Then, during the final zonk, replace TcTyCons with the real, full-blooded TyCons in the global environment. It's all very easy. The new bit is explained in the existing Note [Type checking recursive type and class declarations] in TcTyClsDecls. Naturally, I removed various references to the knot and the zonkTcTypeInKnot (and related) functions. Now, we can print types during type checking with abandon! NB: There is a teensy error message regression with this patch, around the ordering of quantified type variables. This ordering problem is fixed (I believe) with the patch for #14880. The ordering affects only internal variables that cannot be instantiated with any kind of visible type application. There is also a teensy regression around the printing of types in TH splices. I think this is really a TH bug and will file separately. Test case: dependent/should_fail/T15380 (cherry picked from commit f8618a9b)
Showing
- compiler/basicTypes/DataCon.hs 23 additions, 23 deletionscompiler/basicTypes/DataCon.hs
- compiler/iface/BuildTyCl.hs 8 additions, 6 deletionscompiler/iface/BuildTyCl.hs
- compiler/typecheck/FamInst.hs 1 addition, 1 deletioncompiler/typecheck/FamInst.hs
- compiler/typecheck/TcEnv.hs 10 additions, 1 deletioncompiler/typecheck/TcEnv.hs
- compiler/typecheck/TcHsSyn.hs 29 additions, 16 deletionscompiler/typecheck/TcHsSyn.hs
- compiler/typecheck/TcHsType.hs 43 additions, 103 deletionscompiler/typecheck/TcHsType.hs
- compiler/typecheck/TcMType.hs 7 additions, 17 deletionscompiler/typecheck/TcMType.hs
- compiler/typecheck/TcTyClsDecls.hs 36 additions, 28 deletionscompiler/typecheck/TcTyClsDecls.hs
- compiler/typecheck/TcType.hs 7 additions, 17 deletionscompiler/typecheck/TcType.hs
- compiler/types/TyCoRep.hs 6 additions, 0 deletionscompiler/types/TyCoRep.hs
- compiler/types/TyCon.hs 14 additions, 7 deletionscompiler/types/TyCon.hs
- compiler/types/Type.hs 18 additions, 7 deletionscompiler/types/Type.hs
- testsuite/tests/dependent/should_compile/T14066a.stderr 1 addition, 1 deletiontestsuite/tests/dependent/should_compile/T14066a.stderr
- testsuite/tests/dependent/should_fail/T15380.hs 20 additions, 0 deletionstestsuite/tests/dependent/should_fail/T15380.hs
- testsuite/tests/dependent/should_fail/T15380.stderr 6 additions, 0 deletionstestsuite/tests/dependent/should_fail/T15380.stderr
- testsuite/tests/dependent/should_fail/all.T 1 addition, 1 deletiontestsuite/tests/dependent/should_fail/all.T
- testsuite/tests/ghci/scripts/T6018ghcifail.stderr 1 addition, 1 deletiontestsuite/tests/ghci/scripts/T6018ghcifail.stderr
- testsuite/tests/polykinds/T7524.stderr 1 addition, 1 deletiontestsuite/tests/polykinds/T7524.stderr
- testsuite/tests/th/T10267.stderr 3 additions, 3 deletionstestsuite/tests/th/T10267.stderr
- testsuite/tests/typecheck/should_fail/T6018fail.stderr 3 additions, 2 deletionstestsuite/tests/typecheck/should_fail/T6018fail.stderr
Loading
Please register or sign in to comment