Unclear error message
Paul Backus
snarwin at gmail.com
Wed Nov 11 01:44:40 UTC 2020
On Wednesday, 11 November 2020 at 01:05:21 UTC, SealabJaster
wrote:
> Please see the code at https://run.dlang.io/is/Yjidek
>
> As I understand the error is caused by trying to provide a
> delegate when there's no context to provide. Not complaining
> about that.
>
> However what I am complaining about is about the error message:
> `onlineapp.d(31): Error: delegate onlineapp.S.__lambda2 cannot
> be struct members`
>
> I'm not sure if it's just me, but that error message makes
> absolutely no sense to me. Should that message be improved?
Yeah, that message is really bad. The actual problem is that the
compiler isn't able to figure out the type of the lambda you've
provided. If you change the argument to `(string str)`, it'll
work.
The real question is, why does type inference fail for the UDA
when it works for the normal constructor call?
More information about the Digitalmars-d-learn
mailing list