BUG: Use correct return value when ufunc loop matched

Fixes #2506