Bug 23931 – Error: reference to local variable `this` calling non-scope member function `this.this()`
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-05-20T12:10:40Z
Last change time
2023-06-30T08:00:52Z
Keywords
diagnostic, pull
Assigned to
No Owner
Creator
ZombineDev
Comments
Comment #0 by petar.p.kirov — 2023-05-20T12:10:40Z
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
Comment #1 by dlang-bot — 2023-06-29T17:02:47Z
@ntrel created dlang/dmd pull request #15368 "Fix Issue 23931 - Error: reference to local variable `this` calling n…" fixing this issue:
- Fix Issue 23931 - Error: reference to local variable `this` calling non-scope member function `this.this()`
https://github.com/dlang/dmd/pull/15368
Comment #2 by dlang-bot — 2023-06-30T08:00:52Z
dlang/dmd pull request #15368 "Fix Issue 23931 - Error: reference to local variable `this` calling n…" was merged into master:
- 47154c4d59bab15cd5beec94d505a6391955640f by Nick Treleaven:
Fix Issue 23931 - Error: reference to local variable `this` calling non-scope member function `this.this()`
https://github.com/dlang/dmd/pull/15368