Fix #7661 regression.

Patch from singpolyma.