Should Postgres function return/coerce numeric scale/precision?
RETURNS TABLE(m numeric(20,10), n numeric(20,10)) does not enforce the data types of the returned columns; it's simply a declaration, metadata intended to inform the callers what the function should return. The declaration cannot not require anything, it's a &quot;promise&quot; that is to be fulfilled by the function implementation. The function code itself is responsible for what it returns. In other words, you must use explicit type casts, as necessary, in the function body.
If the function doesn't fulfil the promise, it's an implementation bug.

P.S.
Looking at the source code of coerce_type, it simply compares type OIDs, so any numeric is compatible with any other numeric:

    if (targetTypeId == inputTypeId ||
        node == NULL)
    {
        /* no conversion needed */
        return node;
    }