Note [Reporting representation-polymorphism errors]
As explained in Note [The Concrete mechanism] in GHC.Tc.Utils.Concrete, to check that (ty :: ki) has a fixed runtime representation, we emit an equality constraint of the form ki ~# concrete_tv where concrete_tv is a concrete metavariable. In this situation, we attach a 'FixedRuntimeRepOrigin' to both the equality and the concrete type variable. The 'FixedRuntimeRepOrigin' consists of two pieces of information: - the type 'ty' on which we performed the representation-polymorphism check, - a 'FixedRuntimeRepContext' which explains why we needed to perform a check (e.g. because 'ty' was the kind of a function argument, or of a bound variable in a lambda abstraction, ...). This information gets passed along as we make progress on solving the constraint, and if we end up with an unsolved constraint we can report an informative error message to the user using the 'FixedRuntimeRepOrigin'. The error reporting goes through two different paths: - constraints whose 'CtOrigin' contains a 'FixedRuntimeRepOrigin' are reported using 'mkFRRErr' in 'reportWanteds', - equality constraints in which one side is a concrete metavariable and the other side is not concrete are reported using 'mkTyVarEqErr'. In this case, we pass on the type variable and the non-concrete type for error reporting, using the 'frr_info_not_concrete' field. This is why we have the 'FixedRuntimeRepErrorInfo' datatype: so that we can optionally include this extra message about an unsolved equality between a concrete type variable and a non-concrete type.
References 1
- The Concrete mechanism GHC.Tc.Utils.Concrete
Referenced by 3
- GHC.Tc.Errors call site
- Concrete overview GHC.Tc.Utils.Concrete
- substConcreteTvOrigin GHC.Tc.Utils.TcMType