The thing is, you don’t make syntax mistakes on purpose. Especially if you know a language extremely well, a syntax error will happen at random, you won’t notice it (if you did, you would have fixed it), and it therefore becomes invisible to you.
Part of your brain “knows” there’s no error, because you know the language extremely well, and because if you had made an error, you would have fixed it.
This leads to acute, irrational frustration. It’s very human.
There’s not really a solution, just smoke more weed and take your eyes off the screen occasionally.
There is actually an approach for this. Leave the cursed code in, but implement it again in the same file, from scratch, without looking at the cursed code. You’ll either unthinkingly fix the combination of conditions that led to bad code being correct, or you’ll realize why that was what you needed the whole time.