Since this bug was mentioned in https://debbugs.gnu.org/36237, here is a slightly reworked version that does not special-case `concat' in the general code.