Yeah, the general rule is, if it does not work and you have stared at it long enough and STILL cannot work it out, delete it and type it out again.
This does not fix everything (I wish it did) but it does seem to fix some things.
Sometimes your brain tells you what you want to see - you have to be aware of this shortcoming when starting out.
I found this affliction does slowly recede as you spend more time developing and you learn other tricks in order to develop incrementally and code more defensively (using a good IDE will help here too), but when all else fails I will resort to this "just type it again, dummy" especially when tired or during bouts of AFD (alcohol fuelled development - blimey, cannot find that defined on t'internet, must have been a joke between a couple of us ....).
Good luck with things
(off to watch SB #47 and drink beer! Go Niners!)