Added failing test
Use same algorithm for determining type name.

In particular, use the one from `typeof_term_t`.
Merge branch 'gchpaco_3059' into next

Fixes #3059.
Don't permit object-like operations on ptypes
Thread checks in where it makes sense.