Fix Trac #2111: improve error handling for 'rec' in do-notation