# [SAoC 2025] Improving D error messages Weekly Update #3

Iskaban10 sourishjana10 at gmail.com
Mon Oct 6 14:10:48 UTC 2025


## Summary
This week, I focused on DMD’s diagnostic and error reporting 
infrastructure as part of enabling Language Server Protocol (LSP) 
integration. The main goal was to produce structured diagnostic 
data in JSON format that can be easily consumed by editors or 
tools such as `serve-d` and `code-d`.

### 1. Studied DMD’s Diagnostic System
- Understood how `ErrorSink` acts as an abstraction layer for all 
compiler messages (`error`, `warning`, `deprecation`, etc.).
- Traced how diagnostics propagate from parsing and semantic 
analysis to the sink layer.

### 2. Analysed Existing Tooling
- Examined D’s existing ecosystem components: `serve-d` and 
`code-d` for LSP support.
- Studied `sarif.d` and `json.d` in the DMD codebase.
- Found that `sarif.d` is designed for static analysis report 
generation, not for real-time LSP diagnostics.

### 3. Implemented `errorsinkjson.d`
- Created a new module `errorsinkjson.d` defining the class 
`ErrorSinkJson`.
- `ErrorSinkJson` inherits from `ErrorSink` and overrides all 
relevant virtual methods.
- Each diagnostic is serialized into JSON with fields like:
   ```json
   {
       "type": "error",
       "file": "main.d",
       "line": 42,
       "column": 5,
   }
   ```
Work in : [https://github.com/Iskaban10/dmd/tree/lsp](URL)



More information about the Digitalmars-d mailing list