Bug 20078 – Multiple confusing error messages

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2019-07-23T19:58:23Z
Last change time
2023-04-18T11:45:00Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Simen Kjaeraas

Comments

Comment #0 by simen.kjaras — 2019-07-23T19:58:23Z
These functions all have the same underlying issue : struct S { int n; pragma(msg, fun1!(a => n)); pragma(msg, fun2!(a => n)); pragma(msg, fun3!(a => n)); } // Error: value of this is not known at compile time int fun1(Fn...)() { alias F = Fn[0]; pragma(msg, F(0)); return 0; } // Error: this.__lambda2 has no value int fun2(Fn...)() { pragma(msg, Fn[0](0)); return 0; } // Error: function `foo.S.fun3!((a) => a).fun3` need this to access member fun3 int fun3(alias Fn)() { return Fn(0); } However, as indicated by the comments, the error messages are wildly different.
Comment #1 by razvan.nitu1305 — 2023-04-18T11:45:00Z
I now get: test.d(3): Error: need `this` for `n` of type `int` test.d(3): instantiated from here: `fun1!((a) => n)` test.d(11): while evaluating `pragma(msg, this.__lambda2(0))` test.d(3): while evaluating `pragma(msg, fun1!((a) => n))` test.d(4): Error: need `this` for `n` of type `int` test.d(4): instantiated from here: `fun2!((a) => n)` test.d(17): while evaluating `pragma(msg, this.__lambda3(0))` test.d(4): while evaluating `pragma(msg, fun2!((a) => n))` test.d(5): Error: need `this` for `n` of type `int` test.d(5): instantiated from here: `fun3!((a) => n)` test.d(5): while evaluating `pragma(msg, fun3!((a) => n))` So this seems to have been fixed.