This is exactly why you should rest a day before you push a big release to your app/site. After a marathon coding session there are bound to be bugs that will pop up in your dreams, and you'll catch them in time.
Happens to me on a regular basis. I wake up in the night with a solution to a bug I am chasing or some difficult interface that remained unfinished.<p>Sometimes it comes right out of the blue. Last week I awoke in the night with the realisation that there was an "edge case" bug in some code I was due to deliver the next day - and I certainly had not consciously been thinking about that code after I had finished with it - almost the opposite as I had been happy with the run of tests I had applied.<p>The brain is a wondrous organ.
I wish this happened to me. I do often do the "subconcious solves the problems" thing, but "sleeping on it" rarely seems to help, and it usually happens somewhere where I'm a long way away from anything to code on (computer, paper, or otherwise.)<p>Result: I've turned into an obsessive carrier of pens and paper. I've basically come to the realization that my muse strikes unpredictably, without warning, and almost ALWAYS at the least convenient time.
Used to happen to me a lot when I hacked in C. Not so much in PHP. I'm not sure if it's memory handling abstraction or experience. Lately this sort of thing has crept into subtle flaws in business models and ideas.
often times I find solutions to complicated problems while I sleep. But I usually don't spot bugs while I sleep (unless I've been thinking about some particular known issue the day before).