Remove knot-tying bug in TcHsSyn.zonkTyVarOcc
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 31 Aug 2018 10:33:08 +0000 (11:33 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 31 Aug 2018 11:56:44 +0000 (12:56 +0100)
commit565ef4cc036905f9f9801c1e775236bb007b026c
tree75025acdba91366b02d8e432cb57d18271d460b5
parentfda2ea5830176236380a6976dfd0d5802395c6a9
Remove knot-tying bug in TcHsSyn.zonkTyVarOcc

There was a subtle knot-tying bug in TcHsSyn.zonkTyVarOcc, revealed
in Trac #15552.

I fixed it by

* Eliminating the short-circuiting optimisation in zonkTyVarOcc,
  instead adding a finite map to get sharing of zonked unification
  variables.

  See Note [Sharing when zonking to Type] in TcHsSyn

* On the way I /added/ the short-circuiting optimisation to
  TcMType.zonkTcTyVar, which has no such problem.  This turned
  out (based on non-systematic measurements) to be a modest win.

  See Note [Sharing in zonking] in TcMType

On the way I renamed some of the functions in TcHsSyn:

* Ones ending in "X" (like zonkTcTypeToTypeX) take a ZonkEnv

* Ones that do not end in "x" (like zonkTcTypeToType), don't.
  Instead they whiz up an empty ZonkEnv.
14 files changed:
compiler/ghci/RtClosureInspect.hs
compiler/typecheck/TcDefaults.hs
compiler/typecheck/TcHsSyn.hs
compiler/typecheck/TcHsType.hs
compiler/typecheck/TcInstDcls.hs
compiler/typecheck/TcMType.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcSplice.hs
compiler/typecheck/TcTyClsDecls.hs
testsuite/tests/typecheck/should_fail/T15552.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T15552a.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/T15552a.stderr [new file with mode: 0644]
testsuite/tests/typecheck/should_fail/all.T