For the first time, astronomers have caught a star in the act of swallowing a planet, providing a glimpse into how the sun may eventually eat up Earth.