I don't understand this bug

If you look at the reference for the max(), it gives you this warning:

Because of the way the max() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results