better reducedim type inference

Fixes #6672.