Fucking love your example dude.
I've found ChatGPT3 OK for low level stuff, but I stopped using it pretty quickly once I went to trying to get it to help build intermediate stuff.
If its making errors in simple script design, it can't handle more.
It is fab for the basics, but I wouldn't truste it for learning anything else more complex for exactly the reasons you said.
Be liable to write my own backdoors that way hahah