Fix Trac #2587: take account of type lets