It's a known issue ... And probably an unsolvable issue (at least for quite some time to come).
Currently the compiler can only compile the files if they are saved. And that wont change anytime soon (nor far).
Files could be saved to an alternative location for compiling. However, that would mean the IDE would have to change any path specified in config or source. As that can be arbitrary complex, this would introduce a massive chance of getting errors. So that is not a good idea.
Files could be saved, and then restored. That would work. Well as long as there are no file-monitoring tools watching, because they would be triggered.
But for now, nothing of that sort exists.
The previous version will be in the backup folder (if you haven't disabled backup saving). So it isn't lost.
But for quick trial and error tests, and keeping your project as it is... There is no simple solution.
Personally, I put projects under revision management (for me git, but svn or others work too). Then I can always revert them to the last commited revision.
Of course, it adds the need for an extra tool...