You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Isn't the real bug here the fact that calling ipred passes compilation? As far as I could tell the lambda template instantion is inside the scope of the S struct => you cannot call it from fun, since fun may call only const functions and pred is mutable.
dlang-bugzilla (@CyberShadow) commented on 2019-10-15T12:59:51Z
Thanks for looking at this!
(In reply to RazvanN from comment #1)
> As > far as I could tell the lambda template instantion is inside the scope of> the S struct
Hmm! But, shouldn't it infer that since it doesn't access anything other than its arguments, it should not have a context?
I see that ipred is typed as a function not delegate.
> you cannot call it from fun, since fun may call only const> functions and pred is mutable.
Thanks, I actually didn't realize that fun being const was a crucial part of this. I guess the error message could be better.
Vladimir Panteleev (@CyberShadow) reported this on 2019-10-13T17:25:04Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=20298
CC List
Description
///////////// test.d ///////////// struct S { int i; alias field = i; int fun(alias pred)() const { // Doesn't work: //return pred(field); // Works: alias ipred = pred!int; return ipred(field); } alias fun1 = fun!(i => i + 1); } ////////////////////////////////// Error is: test.d(9,14): Error: template `test.S.__lambda5` cannot deduce function from argument types `!()(const(int)) const`, candidates are: test.d(16,20): `__lambda5` test.d(16,15): Error: template instance `test.S.fun!((i) => i + 1)` error instantiatingThe text was updated successfully, but these errors were encountered: