Generated code is much easier to debug when errors can be traced back to the original source.
A compiler can preserve line and column information through tokens and syntax nodes, then use that mapping in diagnostics or debug metadata. Losing locations early forces later stages to guess.
The practical design principles
- Carry source spans
- test nested expressions
- define generated-code mapping
How to apply the idea
Start with one observable behaviour, write down the expected result, and test it under the conditions where people will actually use it. Keep the result reproducible so a later change can be compared against the same baseline. If the implementation cannot meet the expectation, explain the limitation rather than disguising it with a visual flourish.
Check that diagnostics still point to the right source after transformations.
Project status note: this article discusses design and engineering principles. Check the linked first-party project page for current availability and implementation status.

What do you want to say about this?