Compilers can detect errors in the grammar, but they cannot infer what your desired intent was. Even the best compilers in the diagnostics business (rustc, etc) aren't mind-readers. A LLM isn't perfect, but it's much more capable of figuring out what you wanted to do and what went wrong than a compiler is.