
#12549: Panic on ":t datatypeName" ---------------------------------+-------------------------------------- Reporter: johnleo | Owner: johnleo Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | ---------------------------------+-------------------------------------- Comment (by goldfire): Your analysis is spot on. Thank you! The problem is (as you may have suspected) that comment on `newMetaTyVars`. It's just plain wrong. The problem is that we must always obey '''The substitution invariant''' from the eponymous Note in !TyCoRep: {{{ When calling (substTy subst ty) it should be the case that the in-scope set in the substitution is a superset of both: * The free vars of the range of the substitution * The free vars of ty minus the domain of the substitution }}} `new_meta_tv_x` takes care to make sure, as it's building the substitution, that the first point is obeyed. But no one is handling the second point!j Perhaps it was envisioned that `nwMetaTyVars` would be called only on a '''closed''' sequence of tyvars. But the function doesn't say that, and evidently it's not true. (I doubt it ever was!) So it seems the answer is to add an `InScopeSet` parameter to `newMetaTyVars` that should contain the free variables of the type being instantiated. Does that help? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12549#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler