ChatGPT is "just" hallucinating answers, so no surprise here!
Also, keep in mind that ChatGPT-3.5 is used (with temperature 0.7.) ChatGPT-4.0 and/or lower temperatures might be producing much better results.
BTW, I am working on a workaround of the ChatGPT's code hallucinations (when it comes to code generation.) But that workaround only works for code that is already "known and parameterized."