www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23931] New: Improve unhelpful error message

https://issues.dlang.org/show_bug.cgi?id=23931

          Issue ID: 23931
           Summary: Improve unhelpful error message
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: petar.p.kirov gmail.com

The compiler emits an unhelpful diagnostic error message:

fail_compilation/test20245.d(69): Error: reference to local variable `this`
calling non-scope member function `this.this()`

for this file in the test suite:

compiler/test/fail_compilation/test20245.d

since commit:
https://github.com/dlang/dmd/commit/bd2bdae5e0e3ace7eb6eab69d5ebcd77c0dd8d28

The problem is that the message doesn't provide enough information for the user
to understand the problem.

One possible improvement would be:

fail_compilation/test20245.d(69): Error: reference to member variable
`DontDoThis.content` possibly escaped when passed to non-scope member function
`Exception.this()`

Context: https://github.com/dlang/dmd/pull/15249#discussion_r1199164933

--
May 20 2023