Fix Trac #3640, plus associated refactoring
In fixing this bug (to do with record puns), I had the usual rush of
blood to the head, and I did quite a bit of refactoring in the way
that duplicate/shadowed names are reported.
I think the result is shorter as well as clearer.
In one place I found it convenient for the renamer to use the ErrCtxt
carried in the monad. (The renamer used not to have such a context,
but years ago the typechecker and renamer monads became one, so now it
does.) So now it's availble if you want it in future.