[SAOC 2025] Improving D error messages Weekly Update #2
Iskaban10
sourishjana10 at gmail.com
Mon Sep 29 15:12:22 UTC 2025
# [SAOC 2025] Improving D error messages Weekly Update #2
This week I focused on trying to improve the diagnostic quality
of dmd by including the function or constructor name in error
messages i.e. providing the logical location of errors like the
C++ compiler does.
For example -
```
hello.cpp: In function main()
```
## Explored the dmd error working pipeline
+ Studied errors.d, specially printDiagnostic() and
vreportDiagnostic(), where error messages are formatted and
displayed.
+ Reviewed the role of DiagnosticContext and experimented with it
to carry contextual information like the current function name.
+ Explored semantic3.d and funcsem.d to understand the semantic
processing of function bodies.
## Globals and function tracking
+ Experimented with adding a currentFuncName field in globals.d
for globally tracking the active function during analysis.
+ Experimented with using .error() member functions on
FuncDeclaration and other Dsymbol-derived classes to simplify
error reporting.
## Challenges / Issues Encountered
+ **Import cycles**: Adding FuncDeclaration references in
globals.d caused cyclic imports.
+ **Infinite recursion / silent compiler**: Incorrect placement
of function name tracking in semantic3() temporarily suppressed
error output, likely due to recursion.
The git branch I am working on is :
https://github.com/Iskaban10/dmd/tree/improve-error-msg
More information about the Digitalmars-d
mailing list