This looks very much like the sort of errors I used to make for years. I felt like I was getting on all right, but I commonly mis-remembered syntax or started doing something differently and didn't notice. I often couldn't see anything wrong even when it was something very simple. Despite this, I could still type mostly coherent English and my programming errors tended to only show in one specific thing. Typically for me, it was regular expressions.
As such, I respectfully suggest the OP get more fresh air. Carbon dioxide -- the stuff we breathe out -- builds up fast and has a surprisingly stong affect on brain function. I forget the exact figures, but it's easy to build up enough carbon dioxide to halve brain function. Bedrooms have been known to build up even more than that. Ventilation is essential. Sadly, it's sometimes impossible to get enough ventilation; some entire valleys develop unacceptably high carbon dioxide levels on still days. It must also be noted that microbes which consume organic detritus (dirt) also produce carbon dioxide.
As to why this is showing up with MID$ specifically, I recall it being the hardest function to understand when I was little. I don't know why, it just was. I hated it for a while.