www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - [SAOC 2024] Improving D Error Messages Weekly Update #1

reply Royal Simpson Pinto <royalpinto007 gmail.com> writes:


In this first week of Milestone 1, I focused on building an 
understanding of the DMD compiler’s internals, especially how 
error handling works, as I prepare to add SARIF support. I also 
spent time getting comfortable with contributing to the DMD 
codebase and learning more about compiler design.



1. **Learning DMD Compiler Internals:**
    Since my goal is to improve error messages, I started by 
exploring the DMD compiler’s codebase with a focus on how errors 
are processed and reported. Understanding the flow of error 
messages is key for when I integrate SARIF support, which will 
allow error reports to be serialized in a standard format. While 
it’s been a lot to absorb, I’m starting to understand how things 
are connected.

2. **Reading "Crafting Interpreters":**
    My mentor recommended the [Crafting 
Interpreters](https://craftinginterpreters.com/) book, and I’ve 
been focusing on the sections about parsing. Even though this 
book is more about interpreters, the parsing concepts are very 
similar to what happens in compilers. This is helping me get a 
handle on how compilers like DMD break down code and, more 
importantly, how errors are caught and reported during that 
process.

3. **DMD Contribution Setup:**
    Another key task this week was setting up my environment for 
contributing to DMD. I followed the D contributor guide, cloned 
the repository, and built the compiler. Along the way, I 
documented the process, so feel free to check out my notes here: 
[D Contributor Tutorial 
Notes](https://docs.google.com/document/d/1n5jV3czsi8sA1sh4EAP-jwQSAahTJDsYRVMoCSueHcg/edit?usp=sharing).

    Going through previous contributions helped me understand the 
coding standards and how typical issues are handled. I’ll be 
applying these lessons as I start implementing SARIF support.

4. **Compiler Design Playlist (in Hindi):**
    I watched a [Compiler Design 
Playlist](https://www.youtube.com/playlist?list=PL9FuOtXibFjVR-
7LcU-DS-9TJcbG97_p) by Abhishek Sharma, which is in Hindi. It was great for
solidifying my understanding of the basic theory behind compilers, such as
lexical analysis and syntax parsing. Even though this is theoretical, it has
helped me connect the dots between compiler theory and the real code I’m
working on in DMD.

5. **Attending DConf Virtually:**
    I also attended **DConf 2024** virtually, which ran from 
September 18th to 20th. This was a fantastic opportunity to get a 
better sense of the community and see the latest projects and 
features being developed in the D language.



- **Understanding Error Handling and the DMD Codebase:**
   One of the main challenges I faced this week was getting a 
clear understanding of how error handling is managed within the 
DMD compiler. While I’ve been able to pinpoint the key areas 
where errors are generated and processed, the system is quite 
complex and tightly integrated into the broader DMD codebase. It 
will take more time and exploration to fully grasp how everything 
fits together. Additionally, navigating the DMD codebase itself 
has been a learning curve. There’s a lot to absorb, and I may 
need to reach out to the D community for advice and clarification 
as I continue digging deeper.



- Continue focusing on error handling in DMD, trying to 
understand the full process from where errors are generated to 
how they are reported.
- Begin outlining how I’ll integrate SARIF support into DMD and 
start with a basic proof-of-concept, with the help of my mentor.
- Keep learning by exploring more of the DMD codebase and 
connecting with the D community for feedback and suggestions.

---

This week was all about getting familiar with the codebase, 
setting up my tools, and building the necessary knowledge. I’m 
excited to move forward and begin the actual work on improving D 
error messages in the coming weeks.
Sep 22
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Monday, 23 September 2024 at 03:59:12 UTC, Royal Simpson Pinto 
wrote:


 In this first week of Milestone 1, I focused on building an 
 understanding of the DMD compiler’s internals, especially how 
 error handling works, as I prepare to add SARIF support. I also 
 spent time getting comfortable with contributing to the DMD 
 codebase and learning more about compiler design.

 [...]
Silly question: What is SARIF?
Sep 22
parent Royal Simpson Pinto <royalpinto007 gmail.com> writes:
On Monday, 23 September 2024 at 04:17:32 UTC, Nicholas Wilson 
wrote:
 Silly question: What is SARIF?
Hi Nicholas, SARIF stands for Static Analysis Results Interchange Format, which is a standard (in JSON format) used to report errors, warnings, and analysis results in a way that can be easily shared between tools, like IDEs and CI systems. For my project, I’m working on adding SARIF support to the DMD compiler, possibly by providing an option or a compiler flag to output error messages in this format. I’m still clarifying the exact approach with my mentor, but the goal is to make D’s error reporting more versatile and compatible with other tools. If you're curious, you can read more about SARIF here: [SARIF Standard on OASIS](https://www.oasis-open.org/committees/sarif/) and [SARIF support for code scanning](https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning).
Sep 22