Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Can all compiler errors be caught by language server?
Here is the reasoning:
- Compiler error is syntax error
- Language server can catch all syntax error
- Therefore, all compiler errors can be caught by language server
I have the feeling that this is true, based from my understanding on Language Server Protocol - Wikipedia. But the article doesn't explicitly mention any point of above.
If point 3 is true, then we can say that language server catches compiler error without having a compiler. And as the difference between an IDE and a code editor is just whether the compiler is integrated in it or not, then we can redefine IDE as a code editor with language server. Or we can say that as of today, code editor is IDE, and IDE is code editor, and we only need to use one term. The necessity for using the term IDE has ceased to exist. We only use it as a habit.
Why is VS Code considered as a code editor and not an IDE ? : r/vscode
2 answers
Compilers raise many errors other than syntax errors.
A compiler can act as a language server and expose all of the errors it raises through that interface. Not many compilers do this yet, but in principle nothing stops them from doing so.
At our current point in history, though, a compiler is a tool whose primary responsibility is turning source code into executable code, and a language server is a tool whose primary responsibility is exposing information about symbols and errors to an editor. Nothing stops one tool from being written to fulfill both responsibilities, but they are distinct responsibilities.
This started in a comment, but got long and detailed enough that it should be an answer. This answer addresses your first point:
Compiler error is syntax error
No, these are not the same. Syntax errors are errors the compiler catches (I assume that's what you mean by "compiler error".). However, not all errors caught by a compiler are syntax errors.
One example is an assignment to a variable where the expression is a symbol. When that symbol is the name of a variable of the correct type, then that's fine. If the symbol is something that doesn't result in an expression or an expression of the wrong type (depending on language), then it's a compile-time error. However, it is still syntactically correct.
can you give an example for that example? Maybe a piece of code
Consider the Pascal assignment statement:
MyVar := SomeSymbol;
This statement is syntactically correct, since MyVar and SomeSymbol are valid symbol names. If SomeSymbol is the name of a variable that has a compatible type to MyVar, there is no error at all. The same is true if SomeSymbol is the name of a function that returns a value of compatible type. However, it is an error if SomeSymbol is the name of a subroutine, for example.

0 comment threads