this is blowing my mind.
https://youtube.com/watch?v=On2V_L9jwS4
in this video Hank Green says so. they claim that basically, any wet tissue where lots of blood flows through can absorb oxygen from the air, and that lungs did not evolve 300 million years ago when fish stepped out of the water and onto the land, but as early as 420 million years ago, supposedly because it allows fish to survive in water that is depleted in oxygen, as stale warm water often is.
for this purpose, fish would open their mouth and swallow air from above-the-water, sothat the air enters their gut, where oxygen is absorbed into the bloodstream. since the gut has a large internal surface area, this supposedly works; and lungs are just a more efficient version that developed out of this scheme.
wait let me check with wikipedia. https://en.wikipedia.org/wiki/Lung#Evolutionary_origins doesn't seem to confirm or deny it, it just says that lungs developed "from a sack near the oesophagus".
the article Lungenfische (german for lungfish) seems to mention it:
Die Lunge der Lungenfische ist ein Organ am Darm, das homolog zur Schwimmblase ist.
Translation:
The lungs of lungfish are an organ on the intestine that is homologous to the swim bladder.
but the english article about lung fish seems to mention instead:
As in tetrapods and bichirs, the lungs extend from the ventral surface of the esophagus and gut.
so we have "attached to the intestine" vs "attached to the esophagus and gut". i'm not sure.