[SAOC 2024] Improve D Error Messages - Weekly Update #9

Royal Simpson Pinto royalpinto007 at gmail.com
Mon Nov 18 13:34:37 UTC 2024


## Summary of Progress (November 11 – November 17)

This week, I focused on refining error handling, working on 
global implementations, and addressing a few key issues reported 
in the DMD compiler.

### **What I Worked On**

#### **Key PRs:**
   1. fix Bugzilla 24745 - improve associative array syntax error 
message [#16832](https://github.com/dlang/dmd/pull/16832)
       - Improved syntax error messages for associative arrays, 
making them clearer and more user-friendly.

   2. fix Bugzilla 24353 - add mutability check for `foreach` with 
`opApply` [#17071](https://github.com/dlang/dmd/pull/17071)
       - Added a mutability check for `foreach` loops using 
`opApply`.
       - Feedback received highlighted that this bug can result 
from any qualifier mismatch, which can occur on the `opApply` 
method, the `foreach` variable, or both. Addressing only `const` 
on the `foreach` variable fixes the specific example but leaves 
the broader issue unresolved. I plan to address this underlying 
problem comprehensively after completing work on 
`verrors=context`.

#### **Learning and Implementation:**
- Worked on enabling `verrors=context` globally to enhance error 
visualization.
   - Verified no segmentation faults or other issues occur when 
applied globally.
   - Observed outputs can be found here:
     - [Opt-in 
output](https://github.com/royalpinto007/d-drafts/blob/main/opt_in_output.txt)
     - [Opt-out 
output](https://github.com/royalpinto007/d-drafts/blob/main/opt_out_output.txt)
   - Studied the original implementation of squiggles and carets 
from [this 2018 
commit](https://github.com/dlang/dmd/commit/4787d4b4495). It was 
surprising that no one implemented it globally since then, 
motivating me to take on this task.

### **Next Steps:**
- Work on the global implementation of `verrors=context`.
- Address feedback for **Bugzilla 24353** by extending mutability 
checks to the general `opApply` method.
- Continue refining error messages for a better user experience.


More information about the Digitalmars-d mailing list