- Use your Mac notebook where the ambient temperature is between 50° and 95° F (10° and 35° C). Don’t leave your Mac notebook in your car, because temperatures in parked cars can exceed this range. You should also use your Mac notebook where the relative humidity is between 0% and 95% (noncondensing).
source: Keep your Mac notebook within acceptable operating temperatures - Apple Support
The issue per se, is not so much direct sunlight, but more correctly, how hot it gets when exposed to sunlight and while it is operating. Also, in direct sunlight, it becomes harder to read the screen and you would turn up the screen brightness accordingly, this too has a consequence of using more resources (battery energy) and could lead to your Mac heating up to an extent.
As the article above mentions: you do not want to be operating your Mac or other devices in too hot an environment (or too cold for that matter).