However, as you descend into deeper optimization layers of the compiler, errors are less and less likely to occur. Optimizations are either possible or not, though sometimes these layers can warn you about possible inefficiencies at the source code level (unused local, etc.)
using (<span decl>var x = 3</span>) { <span inner>Console.WriteLine(x);</span>}
Parser 0 transforms the using:
<span stmt1 parent=decl>var x = 3;</span> try { <span stmt2 parent=inner> Console.WriteLine(x);</span> } finally { <span stmt3=generated>x.Dispose();</span> }
Parser 1 (or a later parser, inductively) notices x doesn't have Dispose() defined, and throws MissingMethod(Dispose, span=generated).
Parser 0 catches this error, knows that this is because x isn't disosable, and emits its own error: NotDisposable(span=decl).
If a parser doesn't know to catch the error, it still passes it up the chain, transforming spans where appropriate. When it hits the IDE, the error is printed and the red squiggly lines go where they should.
(Disclaimer: I've never written a compiler)