Bug in the function 'diagonal'.

I found a bug in the function 'diagonal'.