Barns have roofs so the animals inside do not get shined on by the sun too much. But when I go inside the barn and close all the metal doors and leave the boarded up windows intact at daytime, I find the lighting is bright despite there not being any flashlights or open windows/doors. Go to google and search barn images, they all have roofs.
I’m pretty sure barns have windows up near the ceiling that let a bit of light through.
However, if you’re talking about the barn not actually having a roof, as in rain/snow is appearing despite that it shouldn’t then it’s probably a bug.
Barns do not have roofs as I’ve seen rain inside of them.
This has been addressed: https://github.com/CleverRaven/Cataclysm-DDA/pull/21593