Note [Error contexts in generated code]

GHC/Tc/Utils/Monad.hs:1211 compiler

* setSrcSpan sets tcl_in_gen_code to True if the SrcSpan is GeneratedSrcSpan,
  and back to False when we get a useful SrcSpan

* When tcl_in_gen_code is True, addErrCtxt becomes a no-op.

So typically it's better to do setSrcSpan /before/ addErrCtxt.

See Note [Rebindable syntax and XXExprGhcRn] in GHC.Hs.Expr for
more discussion of this fancy footwork, as well as
Note [Generated code and pattern-match checking] in GHC.Types.Basic for the
relation with pattern-match checks.